In addition to the resources listed below, the Downloads page also includes important information about getting the source code of MATSim.
Most people will only need the information in "Using Eclipse".
You must have the following software installed and ready to use:
The following steps were tested with the following combination of tools: Java 1.6 Update 15, Eclipse 3.6 SR 1, Subclipse 1.6.2, M2Eclipse 0.12.0.
The main MATSim project includes the API and core implementation of MATSim. It includes everything to start with the basic functionality offered by MATSim and is required in any case.
https://matsim.svn.sourceforge.net/svnroot/matsim". If it does not yet exist, create it.matsim/trunk" and click "next".

The project will be checked out, which may take some minutes. The status of the checkout can be observed in the Progress-View of Eclipse.
After the project appears in Eclipse:
This will convert your project into a Maven/Java project. The first time, Maven may download some required dependencies which can take some minutes. Progress can be observed in the Maven Console View. After that, the project is ready to use.
The "Contributions" provide stable extensions provided by different developers. Some specialized features are not available in the main MATSim project, but must be loaded separately from the contributions.
To check out the contributions, proceed as for the main MATSim project, but this time select the folder "contrib/trunk".

Choose again "Check out as a project in the workspace" and name it "contrib".
After the checkout has finished, right-click on the project and choose "Maven > Enable Dependency Management". After this, materialize the contributions into own projects, i.e. each contribution should become a separate project in Eclipse (at the time of this writing, there is only one contribution named "sna"). To do this, follow these hints.
The "Playgrounds" provide a place for experimental, often unstable code, for each developer. You should only add the Playgrounds to Eclipse if you plan to develop code for MATSim yourself.
Proceed as for the main MATSim project (or for the contributions), but this time select the folder "playgrounds/trunk" to check out and name the project "playgrounds". After the checkout, enable the Maven Dependency Management and materialize the different playgrounds into separate projects. At the time of this writing, there are about 40 playgrounds, so you should see like 40 additional projects in eclipse.
As each contribution and each playground is a separate project in Eclipse, you may end up with quite a large number of projects in Eclipse you likely will not use much (e.g. the playgrounds of other people). While you could remove those projects, it may be better to just close them if you do not need them. Also, to gain some better overview, you can e.g. create a Working set that contains all the playgrounds.
To do this, select menu "File > New > Other ... > Java > Java Working Set".

Name it "matsim-playgrounds", and all the playground projects to it.

After that, in the Package Explorer, click the little triangle in the upper right and select "Top Level Elements > Working Sets".

Now you can easily hide all the many projects so they do not clutter your view.
In the end, you should have the following projects in Eclipse:
matsimcontrib (only if you checked out the contributions)playgrounds (only if you checked out the playgrounds)To use the OTFVis visualizer, one has to configure the path to the native libraries. To do so, go the the Java Build Path settings of the main MATSim project and set the "Native library location" within the Maven Dependencies to the correct directory according to your operating systems. The native libraries are located in libs/jogl-1.1.1/<system-dependent>/lib.

If you get a warning about Eclipse and JDK, you need to configure Eclipse to use a JDK.
Since Eclipse 3.5 it may happen that the code does not compile, even if everything is correctly set up, with the following error message:
Access restriction: The type <<some class name>> is not accessible due to restriction on required library <<some jar file on your system>>
In that case, go to Project Properties, Java Build Path, Libraries. Make sure that the Java version you use is not set to an "Execution environment", but to an "Alternate JRE". After that, the project should compile. It looks like the Eclipse compiler is overly strict when set to an execution environment, forbidding the access to classes that may not be available on all Java installations, but actually are on all major distributions. [Source]

Please note that the way how to install plugins differs from each version of Eclipse to the next one. The following description is for Eclipse 3.5.
http://m2eclipse.sonatype.org/sites/m2e
To make sure the plugin was correctly installed, create a new project using menu "File > New > Project...". There should be a new section "Maven" with several options in it to create Projects based on Maven. Select the option "New Maven Project" and click "Next".
If a warning appears "Maven Integration for Eclipse JDK Warning", you have to configure Eclipse to run on a JDK.
If no warning appears, you're installation/configuration should be complete.
Click "Cancel" to leave the "New Maven Project" dialog.
Please note that the way how to install plugins differs from each version of Eclipse to the next one. The following description is for Eclipse 3.5. See http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA for more detailed information by the plugin provider.
http://subclipse.tigris.org/update_1.6.x
To verify that the integration works, try the following steps:
https://matsim.svn.sourceforge.net/svnroot/matsimmatsim/trunk.
While Subclipse includes everything it needs to run on Windows 32-bit, it has some additional dependencies on Linux and Mac OS X. Especially, Subclipse requires that you have the correct version of Subversion installed on your machine along some libraries to make Subversion usable by Subclipse. Please have a look at the detailed information provided directly by the Subclipse team. For Windows 7 64-bit, see these informations.
Maven allows hierarchical project structures, where one projects can contain one or more modules – which are essentially independent projects. MATSim uses such so-called "multi-module projects" for the Contributions and Playgrounds. Eclipse can generate for each module a project, so you can specify which modules (e.g. contributions, playgrounds) you really need and you will not have to care about the other projects.
To create an Eclipse project for a Maven module (e.g. a specific Contribution or specific Playground), follow these steps:

To create an Eclipse project for a Maven module (e.g. a specific Contribution or specific Playground), follow these steps:

If you have Eclipse Projects representing Maven Modules you no longer need, you can simply delete the Projects in Eclipse's Project Explorer like you delete any other project. Just make sure the option "Delete project contents on disk" is not activated.
Maven requires Eclipse using a JDK, i.e. Java Development Kit, instead of a Java Runtime Environment (JRE). The main difference is that a JDK also contains a Java Compiler and other tools to develop Java Code, while the JRE is only able to run compiled Java applications.
To check with what Java version (JRE or JDK) Eclipse is running, do the following:
Help > About Eclipse". (On the Mac, it's in the Eclipse-menu, not the Help-menu)Installation Details".Configuration"-vm". The line following it shows which Java binary is used.Depending on the name and location of the used Java binary one can figure out if a JRE or a JDK is used:
C:\Program Files\Java\jre6\bin\client\jvm.dll) it is a JREIf no JDK is used for eclipse, change it:
eclipse.ini in a text editor.-vmargs"-vmargs", add two lines:-vm".C:\Program Files\Java\jdk1.6.0_17\bin\javaw.exe" on Windows)You must have the following software installed and ready to use:
The following steps were tested with the following combination of tools: Java 1.6 Update 24, Eclipse 3.7, Subclipse 1.6.18.
The main MATSim project includes the API and core implementation of MATSim. It includes everything to start with the basic functionality offered by MATSim and is required in any case.
https://matsim.svn.sourceforge.net/svnroot/matsim". If it does not yet exist, create it.matsim/trunk" and click "next".

The project will be checked out, which may take some minutes. The status of the checkout can be observed in the Progress-View of Eclipse.
After the project appears in Eclipse:
This will convert your project into a Maven/Java project. The first time, Maven may download some required dependencies which can take some minutes. Progress can be observed in the Maven Console View. After that, the project is ready to use.
The "Contributions" provide stable extensions provided by different developers. Some specialized features are not available in the main MATSim project, but must be loaded separately from the contributions.
To check out the contributions, proceed as for the main MATSim project, but this time select the folder "contrib/trunk".

Choose again "Check out as a project in the workspace" and name it "contrib".
After the checkout has finished, right-click on the project and choose "Configure > Convert to Maven Project". After this, materialize the contributions into own projects, i.e. each contribution should become a separate project in Eclipse (at the time of this writing, there is only one contribution named "sna"). To do this, follow these hints.
The "Playgrounds" provide a place for experimental, often unstable code, for each developer. You should only add the Playgrounds to Eclipse if you plan to develop code for MATSim yourself.
Proceed as for the main MATSim project (or for the contributions), but this time select the folder "playgrounds/trunk" to check out and name the project "playgrounds". After the checkout, convert it to a Maven Project and materialize the different playgrounds into separate projects. At the time of this writing, there are about 40 playgrounds, so you should see like 40 additional projects in eclipse.
As each contribution and each playground is a separate project in Eclipse, you may end up with quite a large number of projects in Eclipse you likely will not use much (e.g. the playgrounds of other people). While you could remove those projects, it may be better to just close them if you do not need them. Also, to gain some better overview, you can e.g. create a Working set that contains all the playgrounds.
To do this, select menu "File > New > Other ... > Java > Java Working Set".

Name it "matsim-playgrounds", and all the playground projects to it.

After that, in the Package Explorer, click the little triangle in the upper right and select "Top Level Elements > Working Sets".

Now you can easily hide all the many projects so they do not clutter your view.
In the end, you should have the following projects in Eclipse:
matsimcontrib (only if you checked out the contributions)playgrounds (only if you checked out the playgrounds)To use the OTFVis visualizer, one has to configure the path to the native libraries. To do so, go the the Java Build Path settings of the main MATSim project and set the "Native library location" within the Maven Dependencies to the correct directory according to your operating systems. The native libraries are located in libs/jogl-1.1.1/<system-dependent>/lib.

If you get a warning about Eclipse and JDK, you need to configure Eclipse to use a JDK.
Since Eclipse 3.5 it may happen that the code does not compile, even if everything is correctly set up, with the following error message:
Access restriction: The type <<some class name>> is not accessible due to restriction on required library <<some jar file on your system>>
In that case, go to Project Properties, Java Build Path, Libraries. Make sure that the Java version you use is not set to an "Execution environment", but to an "Alternate JRE". After that, the project should compile. It looks like the Eclipse compiler is overly strict when set to an execution environment, forbidding the access to classes that may not be available on all Java installations, but actually are on all major distributions. [Source]

We strongly advise developers to use Maven in combination with an IDE, e.g. Eclipse, to develop for MATSim. But there are still situations when Eclipse is not available, for example if you need to run MATSim remotely on a server. These guidelines merely give some hints, how MATSim can be checked out and compiled on the command line, without giving too much information, assuming the reader already has experience and feels safe on the command line.
# Checking out the Code mkdir sandbox cd sandbox svn co https://matsim.svn.sourceforge.net/svnroot/matsim/matsim/trunk matsim svn co https://matsim.svn.sourceforge.net/svnroot/matsim/contrib/trunk contrib svn co https://matsim.svn.sourceforge.net/svnroot/matsim/playgrounds/trunk playgrounds # compile, test and install main MATSim project # installation in the local Maven repository is required for Contributions and Playgrounds to compile. cd matsim mvn install -DskipTests=true cd .. # compile, test, install the Contributions. # installation in the local Maven repository is required because of dependencies from Playgrounds. cd contrib mvn install -DskipTests=true cd .. # compile the playgrounds cd playgrounds mvn compile cd .. # if your playground depends on other playgrounds, those playgrounds must be installed as well: cd playgrounds mvn -fae install -DskipTests=true cd .. # run the Controler with some config-file, and give it 200MB of RAM # mvn exec:java automatically sets the classpath to include all dependencies cd matsim export MAVEN_OPTS=-Xmx200m mvn exec:java -Dexec.mainClass="org.matsim.run.Controler" -Dexec.args="/path/to/config.xml" # alternative call to start the Controler: # mvn exec:exec substitutes the argument "%classpath" with the actual classpath that includes all dependencies mvn exec:exec -Dexec.executable="java" -Dexec.outputFile=/path/to/logfile.log -Dexec.args="-Xmx200m -cp %classpath org.matsim.run.Controler /path/to/config.xml"
If Maven is not installed on the machine, download maven and unzip it in a local directory. After that, instead of the simple mvn-command you can use /path/to/your/apache-maven/bin/mvn to run the above commands.
We highly recommend the two versions above (see Using Eclipse and With Maven on the Command Line). Nevertheless, sometimes one has to pack his own development as a self-executable file that can be started on the command line, since some machines do neither have Maven nor it is allowed to compile/build code there. In such a case it is useful to assemble your playground (or contribution) to a single jar file.
In Eclipse Galileo, the MATSim project and your playground (or contribution) is set up as explained in here.
First, MATSim needs to be packaged as a library in your local Maven repository. For this, create a new Run Configuration: Select Menu Run > Run Configurations..., click on "Maven Build", and press the "New" Button. Configure the build as in the screenshot shown below: Choose the MATSim-project as the base directory, use "install" as the only goal, and add the parameter "skipTests" with the value "true" (Note: The checkbox "Skip Tests" has not the same effect as this parameter, so do not use it!).

After you run that configuration (the first time, Maven might download some additional plugins first), you should see the following final log messages in the "Console" View of Eclipse:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 31 seconds [INFO] Finished at: Fri Jan 08 13:00:14 CET 2010 [INFO] Final Memory: 4M/14M [INFO] ------------------------------------------------------------------------
MATSim is now placed in your local Maven repository at "[path/to/your/home/dir]/.m2/repository/org/matsim/matsim/0.2.0-SNAPSHOT/". There, you should find the following files:
matsim-0.2.0-SNAPSHOT-tests.jar
matsim-0.2.0-SNAPSHOT.jar
matsim-0.2.0-SNAPSHOT.pom
maven-metadata-local.xml
repeat the above steps for installing MATSim, but this time run the install first on the contrib project, then on the playground project. For this, change the Base directory to the corresponding projects.
If the above is done, you now are able to package your playground (or contribution) with all dependent libraries (including MATSim) into one Jar file. This can then be copied and used on any machine that has only JVM installed.
Right-click on your playground (or your contrib) project and choose "Run As > Run Configurations...".

Define a new Configuration by right-click on "Maven Build", select "New" and set up the new configuration as shown in the Figure above (instead of "balmermi", use the name of your playground in the base directory). Run that Configuration whenever you want to create the Jar.
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.523s
[INFO] Finished at: Mon Jun 28 09:41:47 CEST 2010
[INFO] Final Memory: 10M/81M
[INFO] ------------------------------------------------------------------------
If the final log messages in the "Console" View of Eclipse looks like the above the Jar is created and can be found at "[path/to/your/workspace]/playgrounds/[yourPlayground]/target/[yourPlayground]-0.2.0-SNAPSHOT-jar-with-dependencies.jar".
Finally, copy the final Jar file to the machine where you want to run your process and start it via:
java -Xms123m -Xmx456m -cp [yourPlayground]-0.2.0-SNAPSHOT-jar-with-dependencies.jar playground.[yourPlayground].[xyz].[yourMainClass] [arguments]
[[might be easier to just ignore this section until the problem acutally happens]]
moved, see here.
We observed several times that Eclipse freezes when enabling the maven dependency manager for the first time. If this happens, we suggest the following: (i) kill Eclipse (ii) start Eclipse again (iii) disable maven dependency management (right click on project, Maven > Disable Dependency Management) (iv) enable maven dependency management again. In the second try, things usually work.
mvn phasename
-DskipTests option (former: -Dmaven.test.skip=true option)mvn assembly:assembly