Info on JMRI:
Development tools
Code Structure
Functional Info
Techniques and Standards
How To
Background Info

JMRI: Building with Eclipse

Eclipse (available at www.eclipse.org) makes a great platform for working with JMRI, but because the repository is not set up as an Eclipse project there are a few wrinkles in getting it work. (The description below is accurate for version Eclipse 3.2.2 for MacOS X. Eclipse is supposed to be identical across platforms, but this hasn't been checked on anything else).

Eclipse is a complex environment to work with. If you're already familiar with IDEs like Microsoft Visual Studio it won't be too hard to get used to, but it is definitely worth buying a textbook (e.g. The Java Developer's Guide to Eclipse).

On this page, we have our current instructions for getting JMRI working in side Eclipse, followed by older instructions. Another version is available in a JMRIusers post.

Setting up Eclipse for building JMRI

Unfortunately, we don't know how to properly put the Eclipse configuration information directly into CVS, so there are a number of manual setup steps you'll have to take.

  1. Create an empty directory, which will be your Eclipse workspace for JMRI.
  2. Open Eclipse. When it asks for a workspace, select the empty directory you just created.
  3. From the "Window" menu, select "Show View", then "Other..."
  4. In the "Show View" window that just opened, expand the "CVS" folder select "CVS Repositories", and click OK.
  5. A "CVS Repositories" pane will open. If you have any defined already, they'll show. Right click (or CTRL-Click with a one-button mouse) on an empty part of the window, then in the pop-up menu select "New..", then "Repository Location".
  6. Fill out the form that shows up:
    • Host is "jmri.cvs.sourceforge.net"
    • Repository path is "/cvsroot/jmri"
    • User is "anonymous" (if you're a JMRI developer authorized to change CVS, put your sourceforge ID here)
    • Leave password blank
    • Leave the rest of the form at defaults (unless you're a JMRI developer, in which case select "ext" as the connection type)
    • Click "Finish"
  7. If all is well, an entry should show up in the "CVS Repositories" tab. You can close that tab now if you'd like.
  8. From the file menu, select "Import.." In the resulting "Import" window expand the CVS folder and select "Projects from CVS". Click "Next"
  9. Select "Use existing repository location", and highlight the repository entry you just created that refers to JMRI. Click "Next"
  10. Select "Use specified module name" and enter "eclipse" (all lower case). Click "Finish"
  11. If all is well, you'll see a "Checking out..." window while the files are pulled from CVS. This will take a while. When it's done, you'll have all the JMRI code in your workspace directory, and just have to configure Eclipse to run it.
  12. From the "Window" menu, select "Show View ..." then "Navigator". You'll get a multi-pane window that shows various views of the JMRI code.
  13. From the "Run" menu, select "Run..." We'll use the window that opens to configure which program(s) to run.
  14. On the left side, highlight "Java Application", then press the "New" icon above it. The icon looks like a document with a plus sign on the upper-right.
  15. You should now have a new "Main" tab highlighted. Above that, replace "New_configuration" with "DecoderPro". Below it, enter "java" (lower case important) for "Project:" and "apps.DecoderPro.DecoderPro" for "Main class:".
  16. Select the "Arguments" tab, and under VM argments enter
    -Djava.security.policy=lib/security.policy -Dpple.laf.useScreenMenuBar=true -Xms10m
    

    (You should probably cut and paste that). Under working directory, select "Other:" and enter "${workspace_loc}"
  17. Select the "Common" tab, the section on "Display in favorites menu", check the boxes next to "Run" and "Debug"
  18. If you'd like to create targets to make it easy to run PanelPro and AllTests, repeat the above steps to create a new "Java Application" except specifying "apps.PanelPro.PanelPro" and "apps.tests.AllTest" respectively.
  19. Click "Apply", then "Close" (You could click "Run" at this point, but we've got a little more to do)
  20. You should now be back to the usual Eclipse navigator view, where most development work is done. To see some particular java file, expand the "java" folder at the left, then the "src" folder, navigating down to the file you want.
  21. To run DecoderPro, select it under "Run History" from the "Run" menu. Once you've done that once, you can just click the "Run" icon on the toolbar to rerun the last program.

Older version of instructions

Checking out code

Getting Ready to Build

You've now got the code, but it isn't set up for Eclipse to build it or work with it. The next step is to exit Eclipse, as you need to do a couple of things "behind its back".

You can also use ant to build and run the program.

Updating the code from CVS

From time to time, you can update the code to match the current repository contents.

.project :

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>jmri</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

 

.classpath :

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="test"/>
    <classpathentry kind="lib" path="lib/collections.jar"/>
    <classpathentry kind="lib" path="lib/comm.jar"/>
    <classpathentry kind="lib" path="lib/crimson.jar"/>
    <classpathentry kind="lib" path="lib/jdom-jdk11.jar"/>
    <classpathentry kind="lib" path="lib/jh.1.1.2.jar"/>
    <classpathentry kind="lib" path="lib/jh.jar"/>
    <classpathentry kind="lib" path="lib/junit.jar"/>
    <classpathentry kind="lib" path="lib/jython.jar"/>
    <classpathentry kind="lib" path="lib/log4j.jar"/>
    <classpathentry kind="lib" path="lib/MRJAdapter.jar"/>
    <classpathentry kind="lib" path="lib/Serialio.jar"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="output" path="classes"/>
</classpath>