-
Notifications
You must be signed in to change notification settings - Fork 0
Install
Note: These instructions are geared towards developers who want to set up a development environment using Eclipse or Netbeans. If you'd prefer to work exclusively from the command line, check out GettingStartedMaven.
This set of tutorials is designed to guide you through the process of getting started with OpenTripPlanner. After you have followed these instructions, you will have a development environment for OpenTripPlanner set up and will also be able to do rudimentary multi-modal trip planning using the web UI.
We currently have two main options for development environments:
- Eclipse
- Netbeans
The majority of developers contributing to the OTP project are using Eclipse, and instructions for Netbeans were added in October 2011 and have not been actively maintained. So, if you have a strong preference for Netbeans you can check out what we know so far about OTP and Netbeans in the Getting Started in Netbeans page. Otherwise, continue below to use Eclipse.
Most of these instructions are dedicated to getting the various development tools installed and configured properly. If you're an Eclipse wizard or already have some of these tools installed, you'll be able to skip some of these steps. However, unless you have a significant amount of experience developing Java web applications using Eclipse, Maven, and Tomcat, it's recommended that you follow these instructions all the way through to make sure you get set up properly.
Before we start, a quick and very high-level overview of what we're going to do.
-
Install Eclipse along with several plugins that will make development much easier. We will also install and configure Tomcat, which we will run inside of Eclipse to test out the OpenTripPlanner API and web front-end.
-
Use the
opentripplanner-graph-builder
utility to compile a graph using your GTFS data.opentripplanner-graph-builder
will use the locations of the stops in your GTFS data to automatically download OpenStreetMap data for the regions directly around those stops. -
Run
opentripplanner-api-webapp
(the RESTful web service) andopentripplanner-webapp
(the web front-end) and test out the trip planner.
The first thing you will need to do is make sure you have Eclipse installed as well as the M2Eclipse and EGit plugins for Maven and Git support inside of Eclipse. You can do this by following the GettingStartedEclipse tutorial. Note: Since we'll be testing out the web components of the project, you'll want to install the optional Web Standards Tools, as described in .
As of July 2012, we are using Project Lombok for OTP. It is designed to cut down on the amount of boilerplate code we have to write. All new code should use Lombok @Getter and @Setter (unless there is a good reason why not), since this will reduce errors caused by code duplication.
We will transition the older code over as we have time (patches accepted!)
You now need to configure your IDE to use Project Lombok. Maven will automatically install a copy for command-line builds, but you also need to configure Eclipse or Netbeans to use it. The two are completely independent. First, download the Lombok jar here: http://projectlombok.org/download.html
Then run lombok.jar (by double-clicking it or running java -jar lombok.jar in a terminal). This should present you with a GUI wizard that will install Lombok support in your IDE. If this does not work (for example, if you see lots of errors in Eclipse about missing getter and setter methods), take a look here: http://stackoverflow.com/a/9805990/778449
You will want to check that your eclipse.ini contains the following lines (except with the correct path to your copy of lombok.jar):
-javaagent:/home/novalis/eclipse/lombok.jar
-Xbootclasspath/a:/home/novalis/eclipse/lombok.jar
Make sure you install Lombok when Eclipse is not running, or at least restart it once Lombok is installed.
The next thing you need to do is install the Tomcat servlet container and set it up to run inside of Eclipse. Follow the instructions on , making sure to add both the opentripplanner-api-webapp
and the opentripplanner-webapp
project modules to the server. Don't worry about starting the server yet, we'll do that in a later step.
You can learn more about the opentripplanner-graph-builder
module on the GraphBuilder page. For the purposes of this tutorial, you need to create a graph-config.xml
file based on this sample file, updating the path to the GTFS zip file to the be correct for the data you want to use. You will also need to update the path to where you want to write the compiled graph. If you are on Windows, you will also need to change the cacheDirectory
path used to store the OpenStreetMap data to something other than /tmp/osm
.
Now, select the opentripplanner-graph-builder
project inside of Eclipse and choose Run -> Run Configurations. Create a new Java Application configuration .
Under the Arguments tab, put the path to the graph-config.xml
file you just created in the text area labeld Program arguments. You will also likely want to increase the amount of RAM allocated for the Java VM. To do this, add the following under VM arguments: -Xmx2048m
(this will allow the Java VM to consume up to 2GB before running out of space). Run this configuration and go grab a cup of coffee while OpenTripPlanner downloads the appropriate OSM data and compiles the graph.
The last thing you need to do is configure and run the web app in Eclipse. See or RunningTheWebappInTomcat.
Having problems getting your own instance of OpenTripPlanner up and running? Check out the section to see if there's a known fix for your problem.
For a list of all tutorials, see Tutorials.
Todo - create binary releases of OTP Releases