Using Eclipse for MATSim Development

This article shows you how to configure Eclipse to develop MATSim. Eclipse is a powerful, open source development platform with excellent support for Java development. Note that Eclipse is neither required to use MATSim, nor is it the only development environment MATSim works with. It is just one of the many widely used tools by Java developers which we have good experience with.

Installation of a Subversion-Client for Eclipse

MATSim uses Subversion (SVN) as code repository. Currently, there are two well-known plugins that bring svn-functionality to Eclipse:

Both plugins offer very similar features. Install one of them according to their installation instructions. For this article, Subclipse was used, but Subversive should work very similar, so you're free to choose whichever you want.

Checking out the Project from the Subversion Repository

  • Create a new project in Eclipse (menu File > New > Project...).
  • Choose "SVN > Checkout Projects from SVN" and click "Next".
  • Select "Create a new repository location" and click "Next".
  • Enter the URL "https://matsim.svn.sourceforge.net/svnroot/matsim" and click "Next".
  • Select the folder "matsim/trunk" and click "Next".
  • Select "Check out as a project configured using the New Project Wizard", click "Finish".
  • Select "Java > Java Project" this time and click "Next".
  • Enter a project name (e.g. "matsim") and make sure "Create separate folders for sources and class files" is selected in the category "Project layout", click "Next".
  • Set the default output folder to "matsim/classes", then click "Finish".**

If a warning shows, that some files may be overwritten, click "OK".

The project is now checked out from the repository, this is likely to take some minutes to finish.

 

** Note: MATSim also provides a Makefile for command line compilation (i.e. make clean ; make compile ; make run). There, the default class folder is defined as matsim/classes. So---for convenience---we use the same in the eclipse environment.

Configure the Project

Adding Java Libraries

MATSim uses several libraries, which must be added to the build path to successfully compile MATSim. All the libraries are located in the directory libs. Add them to the build path. Maybe the easiest way to do this is to open the Project Properties (Menu Project > Properties), select "Java Build Path", "Libraries", than "Add JARs". Select all the files in libs and click "OK".

Note that you also have to add the bunch of .jar files in the subdirectories of libs except those in libs/source. E.g. add all .jar files of  the libs/geotools folder.

Adding the Test Cases

MATSim includes a growing list of unit tests based on JUnit.
Open the Project Properties (Menu Project > Properties), than select "Java Build Path".
In "Source", click on "Add Folder..." and activate the tick at "test/src", click "OK".
Change to "Libraries" and click on "Add Library...". Choose JUnit, and when asked decide for JUnit 3, not for JUnit 4.
Click "OK" to close the Project Properties.