JMRI: Building with NetBeans
- Introduction
- Getting and Installing NetBeans
- Checking out code
- Building and running JMRI
- Updating the code from SVN
- Making a Jar File
- Making a Patch File
Introduction
NetBeans 7.0 (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 Windows version of NetBeans 7.0. 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 7.0 web site will be helpful.
Getting and Installing NetBeans
- Download NetBeans 7.0 (The Java SE version is fine) from www.netbeans.org
(If you don't yet have Java Development Kit 6.0 (JDK) installed on your system, download a JDK-NetBeans bundle from the NetBeans download page) - Run the NetBeans package installer
Many Linux distributions have NetBeans available in their software repositories - search your package manager for NetBeans.
Checking out code
The easiest way to get the initial copy of the code is to directly check it out using NetBeans' integrated SVN. Once you've done that, NetBeans will automatically use it.
Start NetBeans and do the following steps. Text in brackets [] are menu items to be selected
or buttons to be pressed.
Text in this font should be typed into NetBeans exactly as written.
This font denotes explanations and stage directions to follow.
- Repository URL: https://jmri.svn.sourceforge.net/svnroot/jmri/trunk/jmri
- User: leave empty
- Password: leave empty
- [Next >]
- Repository Folder(s): trunk/jmri
- Repository Revision: leave empty
- Skip "jmri" and checkout only its content: leave unchecked
- Export a clean directory tree from the repository: leave unchecked
- Local Folder: pick somplace on your hard drive...
- Scan for NetBeans Projects after Checkout: ensure checked
- [Finish]
[Window]->[Output]->[Output] shows SVN activity log window...
- wait a few minutes for the SVN checkout to complete
A popup will display stating that 2 projects were checked out and asking if you want to open the projects. - [Open Project...]
- In the Open Projects popup, choose JMRI
- [Open]
Building and running JMRI
To build and run DecoderPro, all you have to do is select "Run Project (JMRI)" from the Run menu, or click the Run icon in the tool bar.
- Run -> Run Project (JMRI) will compile and invoke DecoderPro
- You can choose other targets (i.e. PanelPro...) by changing [File]->[Project Properties (JMRI)]->[Build and Run]->[Run Project]
If you want to run the program under the NetBeans debugger, first set JMRI to be the Main project via [Run]->[Set Main Project]->[JMRI] then select "Debug Main Project" from the "Debug" menu.
Updating the code from SVN
From time to time, you can update the code to match the current repository contents. To do this, use the [Team]->[Update] menu choice.
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 "JMRI" project in the "Projects" 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:
- From the [Team] menu, select "Export Diff Patch ..."
- A file browser will open; enter a new file name in your preferred location and hit "Save" or "Open", depending on what the dialog shows.
- After it finishes calculating the diffs, the file you selected will contain the patches, along with an information header.