JMRI: Building with NetBeans
NetBeans 5.5 (available at www.netbeans.org) makes a great platform for working with JMRI. The JMRI code is setup to work with NetBeans with almost no additional setup. (The description below is accurate for the MacOS X version of NetBeans 5.5. NetBeans is supposed to be identical across platforms, but this hasn't been checked on anything else).
NetBeans is a very powerful Integrated Development Environment (IDE), which can make working with the JMRI code pretty easy. But it takes a little getting used to, and reading the tutorials on the NetBeans web site will be helpful.
Checking out code
The easiest way to get the initial copy of the code is to directly check it out from CVS. Once you've done that, it's easy to get NetBeans to use it. We provide brief instructions here, but if you want to know more about CVS or get a copy of it for your computer, please see our "getting the code via CVS" page.You can download the most recent source code via CVS using:
cvs -d:pserver:anonymous@jmri.cvs.sourceforge.net:/cvsroot/jmri login cvs -d:pserver:anonymous@jmri.cvs.sourceforge.net:/cvsroot/jmri co all(If asked for a password, just hit return)
This will create a number of subdirectories, including one named "java" that we'll reference below.
The first time you build JMRI with NetBeans, you have to tell it how to find the "JMRI Project", which contains the code. After that, you can just reopen the project from the "Open Recent Projects" list in the File menu, or the list of projects in the Projects window pane.
- Start NetBeans
- From the "File" menu, select "Open Project"
- A file-selector window opens
- In the "File Format:" box at the bottom, select "Project Folder"
- Navigate to the "java" folder created above, which will have a slightly different icon. Select it, but don't double click it to open it.
- Click "Open Project Folder"
The project is now open and available for use.
Building and Running JMRI
To build and run DecoderPro, all you have to do is select "Run Main Project" from the Run menu, or click the Run icon in the tool bar.If you want to run the program under the NetBeans debugger, select "Debug Main Project" from the "Run" menu.
Updating the code from CVS
From time to time, you can update the code to match the current repository contents. To do this, select the "Update All Files" from the CVS menu.
Making a Jar File
Most of the code in a normal JMRI installation lives in a file called jmri.jar. If you want to replace this with your updated version, you need to create a new jmri.jar file from your modified code.
To do this,
ctrl-click (or right-click) on the name of the "java" project in the
"Navigator" window. This will open a pop-up menu, on which you'll
find "Make Jar FIle". Select that, and a new jmri.jar file will be
produced in the project's main directory.
Making a Patch File
A "diff patch file" is an easy way to gather up all your changes, even
if they span multiple files, into one file that you can then send to us.
It's also easy to merge in with the rest of the code, so we greatly
prefer that you use this.
To create the file:
- Start NetBeans and open your project
- In the code navigation tree to the left, select the top level "JMRI" project folder
- From the "CVS" menu, select "Export "JMRI" Diff Patch ..."
- A file select directory will open; enter a new file name
in your preferred location and hit "Save" or "Open",
depending on what the dialog shows.
(Note: On some Java versions, there's a bug that only allows you to select existing files whose name ends in ".diff". If that happens, cancel the save dialog, use an editor to create an empty file of that name, and try again)
- After a little while, the file you selected will contain the patches, along with an information header.