Here are some basic principles I like to apply to my open source projects:

  1. A binary version should be available for download.  Not everyone is a developer.
  2. The project should use a public source-code repository and include build instructions.
  3. Build instructions should be easy to use, with a minimal amount of dependencies.

With these principles in mind while preparing to release a project based on the Netbeans Platform, I was a bit dismayed that there was no simple way to build the project from the command line like there is for non-netbeans platform applications, so I turned to Google and put together a single re-usable solution pieced together from other people’s suggestions.

Keep in mind, this is how to build, not how to develop Netbeans platform applications, without the IDE.  If you are developing platform applications, the IDE really is the way to go….


When a project is opened in the Netbeans IDE,  files are created in ./nbproject/private that set properties which allow the build scripts to locate and use the platform’s modules and custom Ant tasks.  The properties will vary by machine based on the installation location of the Netbeans IDE and the name of the user.

In order to setup the platform on a non-Netbeans machine, the platform must first be downloaded, then the build scripts updated to point to the download directory.  To accomplish these tasks, an Ant script can be used (The same tasks could easily be accomplished by batch files or bash scripts, but Ant provides a portable solution).  Netbeans projects already contain a build.xml script, but it cannot be re-used since it relies on the very properties that have yet to be set.  The solution is to create a second Ant script that will download the platform and configure the required properties.


The configure.xml script contains three targets:  download (download the Netbeans platform to a local directory), configure (set properties to use the downloaded platform), and clean (remove the platform and clear properties).   To use:

  1. Download configure.xml and save in the root directory of your Netbeans platform project.
  2. In configure.xml, modify the “version” property to match the desired Netbeans platform version (currently 2.7.1).
  3. Download and configure the platform by running “ant -f configure.xml”.
  4. Build and run the application using “ant run”.

To remove the downloaded platform (for example, to use the platform provided by the IDE), run “ant -f configure.xml clean”.  This will remove the netbeans-${version} directory and the file, which will be re-created by the IDE or the next time “ant -f configure.xml” is run.



Tagged with →  
Share →