PLANit-Java
In this section we detail how to install PLANit-Java.
Prerequisites
- Java 11 or higher
- It likely also works with Java 8 or higher, but this is not tested
- A Java compatible IDE such as Eclipse
- Other IDEs are equally suitable, but we assume Eclipse is used
Installing Java
For personal use and academics it is easiest to stick to the Oracle implementation since these are up to data and free of charge for non-commercial use. Java 11 can be downloaded from:
Commercial use if you want to use PLANit-Python, extend it, and embed it in a commercial product, you best avoid using the Oracle Java implementation unless you are willing to pay a subscription fee or get into trouble later down the road because of proprietary components even in their openJDK implementation. No worries though, there are other capable open-source openJDK implementations. Some links below:
- Unix/Linux based openjdk distributions
- adoptopenJDK for Windows and Mac
After the download, install Java and add it to your path. In case you did not include it in the path during installation; here are the steps to do so manually:
Windows:
- Locate the installation directory of Java
- Find and open the ‘environment variables’ window, for example via the control panel
- Under the system variables, find the ‘path’ entry. Open it, and add a new line with the installation directory of Java supplemented with
/bin
since the executables we want on the path are in the/bin
directory - Apply the changes, close your console window
Mac:
- Locate the installation directory of Java
- Open a terminal and enter : sudo nano /etc/paths. Enter your password when prompted. (nano is a text editor to edit the path in)
- The directories currently part of your PATH appear, now add a new line with the installation directory of Java supplemented with
/bin
since the executables we want on the path are in the/bin
directory. - Press control + X to quit and Y to save changes
Open a new console window, and try java -showversion
, it should now show the version and some additional options
Installing Eclipse
Eclipse is a versatile Integrated Development Environment (IDE) with very good Java support. You can download it here (you likely want to go for the Eclipse IDE for Java Developers):
You can of course use another IDE if you prefer
Setting up PLANit-Java
There are multiple ways to include PLANit into your Java project:
- Compile the sources yourself
- Download precompiled sources from this website
- Include PLANit repositories as Maven dependencies (recommended)
Compiling sources yourself
To compile the sources yourself, head over to the community section and follow the links to the source code repositories hosted on GitHub. In case trhe repository you’re looking for is not (yet) public, please send an email with your request to info@goplanit.org.
download precompiled sources
For each release, we provide precompiled jars and sources on the website. To find the jars (and sources) first select the version you are after by going to the version specific website using the “releases” drop-down menu option in the top bar. Then go to the Documentation/PLANit-Java/Downloads section and you should find what you are looking for. Include the jars in your project and off you go!
Make sure you also download the dependencies of each jar since they are not included. These can be found in the pom.xml file of each repository. Alternatively consider using Maven to build your project in which case you can add the dependencies there (which is much preferred)
Add PLANit as Maven dependency
The recommended way however to include PLANit in your workflow is to simply add it as a dependency via you Maven build process. Each PLANit repository has its own group id, artifact id and version to uniquely identify it. The projects are currently not (yet) hosted on Maven central or one of the other major repository locations. Instead, you will first need to add the PLANit repository to your pom by adding the following:
...
<repositories>
<repository>
<id>planit-repository.goplanit.org</id>
<name>PLANit Repository</name>
<url>http://repository.goplanit.org</url>
</repository>
</repositories>
...
Now Maven will also look for repositories here and will find the recently released versions. To add specific dependencies to your project you then simply add them to your dependencies section of your pom via, for example,
...
<!-- including planit-core v 0.3.0 as a dependencies -->
<dependencies>
<dependency>
<groupId>org.goplanit</groupId>
<artifactId>planit-core</artifactId>
<version>0.3.0</version>
</dependency>
</dependencies
...
Below you will find the various PLANit repository dependencies snippets that can currently be used and are hosted on (repository.goplanit.org)[www.repository.goplanit.org].
Repo | GroupId | ArtifactId | Earliest version |
---|---|---|---|
PLANitParentPom | org.goplanit.parentpom |
planit-parentpom |
0.3.0 |
PLANitUtils | org.goplanit.utils |
planit-utils |
0.3.0 |
PLANit | org.goplanit |
planit-core |
0.3.0 |
PLANitIO | org.goplanit.io |
planit-io |
0.3.0 |
PLANitXMLGenerator | org.goplanit.xml |
planit-xml |
0.3.0 |
PLANitOSM | org.goplanit.osm |
planit-osm |
0.3.0 |
PLANitMATSim | org.goplanit.matsim |
planit-matsim |
0.3.0 |
PLANitTNTP | org.goplanit.tntp |
planit-tntp |
0.3.0 |
PLANitGTFS | org.goplanit.gtfs |
planit-gtfs |
0.3.0 |
PLANitJ2Py | org.goplanit.python |
planit-j2py |
0.3.0 |
PLANitIntegrationTest | org.goplanit.test.integration |
planit-integrationtest |
0.3.0 |
Note that many PLANit repos depend on other PLANit repos. These are automatically resolved by Maven, so you do not need to worry about them (unlike when using any of the other build options)
Getting Started
Now that you have installed all the necessary components. Have a look at the Getting Started, to create your first PLANit-Java application