Skip to content

Setting up a development environment in Eclipse

Andrew Byrd edited this page Dec 17, 2014 · 1 revision

Eclipse

Eclipse is a very widely used open source IDE for development in Java and other languages. This text was written using Eclipse "Luna" version 4.4. Eclipse provides packages with various combinations of plugins included for development in various languages and environments. We used to recommend getting the Java EE package of Eclipse for OTP development but OTP has become much simpler recently. The "Standard" package now contains everything necessary to work on the master branch.

My first impression on trying this new release of Eclipse after several months working with IntelliJ IDEA is that Eclipse is still awkward and crash-prone. Within minutes of installing Luna it had crashed three times and locked up badly enough that I had to kill its JVM. There were also severe menu rendering problems, which to be fair might be caused by my OS rather than Eclipse itself.

Eclipse can be downloaded from https://www.eclipse.org/downloads/. Once you have extracted the package, you can run the eclipse binary in the root of the distribution. When you first start Eclipse or update any components, a maximized "Welcome" tab will appear obscuring the entire interface. Close this tab to gain access to the UI.

Configuration and import

First you will need to install a Maven plugin since OTP uses the Maven build system. Choose Help -> Install new software (why this is on the Help menu I have no idea). In the "Work with" field at the top of the dialog, choose the Luna release server, then search for "Maven" using the filter field. Check the plugin "m2e - Maven integration for Eclipse" under the "General purpose tools" heading and click though the pages to complete the installation. You won't need any of the m2e EE "connector" modules unless you want to deploy OTP to a servlet container from within Eclipse, which is probably more trouble than it's worth unless you have a very good reason. The "Marketplace" option on the Help menu is intended to improve the experience of installing Eclipse components, but Eclipse crashed when I tried to open it.

Now you should have the ability to import Maven projects like OTP. First, you will need to clone the OTP Git repository. Eclipse provides tools to clone the repository from within the IDE GUI then import the Maven project in one step, but this involves installing some m2e SCM connectors via the Marketplace. Considering my negative experience with that tool, I recommend just using Git command line tools to clone the OTP Git repository to a local directory before importing it. This can be accomplished with git clone https://github.com/opentripplanner/OpenTripPlanner.git. Next, go to File -> Import and choose Maven -> Existing Maven Projets. In my experience, clicking the "Browse" button causes an empty window to appear and will lock up or entirely crash Eclipse, so it's better to just type or paste the path to your local clone of the OTP repository into the text field.

Running OTP

As in other IDEs, you need to create "run configurations" to start up a Java program. These can be edited via a dialog available in the menus at Run -> Run configurations, or via the small downward black triangle to the right of the "run" button in the toolbar (the triangular green play icon). In this dialog box, choose the "Java Application" category and click the "empty page" icon with a plus sign on it to create a new configuration. You'll probably want at least two configurations to start: one to build a graph and one to start a server. In both cases your main class will be org.opentripplanner.standalone.OTPMain. You can either type or paste this class name into the "main class" field or click the "Search" button to its right and search for "OTPMain". In the Arguments tab, you will probably want to specify VM arguments to increase the JVM heap size (e.g. -Xmx4G to increase the limit to 4GB). Only the "Program arguments" will be different for building and serving a graph (see "Standalone Graph Build" [article to be completed]).

Once run configurations are defined, you can launch them from within the dialog box by selecting one and hitting the "Run" button. Recently launched run configurations can be found in the dropdown menus to the right of the green "run" button and the debug icon next to it in the toolbar.

The documentation on this wiki is outdated and should not be used

unless you are intentionally working with legacy versions of OpenTripPlanner. Please consult the current documentation at readthedocs

Clone this wiki locally