With Maven on the Command Line

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.


Warning: Table 'watchdog' is read only query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '<em>Table &amp;#039;sessions&amp;#039; is read only\nquery: UPDATE sessions SET uid = 0, cache = 0, hostname = &amp;#039;38.107.179.230&amp;#039;, session = &amp;#039;&amp;#039;, timestamp = 1328350514 WHERE sid = &amp;#039;e972b2ab7dd755a2094beea8ac708f02&amp;#039;</em> in <em>/home01/vsp_access/matsimwww/includes/database.mysql.inc</em> on line <em>174</em>.', 2, '', 'http://matsim.org/node/368', '', '38.107.179.230', 1328350514) in /home01/vsp_access/matsimwww/includes/database.mysql.inc on line 174