A Rough Guide to James Development Using NetBeans
Follow these steps to develop James code using the NetBeans IDE. Use the NetBeans Help and Tutorials to more fully understand the NetBeans concepts and actions described here.
We assume that NetBeans has been downloaded and installed from http://www.netbeans.org/. The NetBeans release we refer to is 5.0+.
We also assume that also the James project files have been downloaded from the Apache SVN repository and are available in a directory that we will refer to as [james-prj]. We will assume also that a working James server runtime instance has been already "deployed" in a directory that we will refer to as [james-rt], and all configuration files are already set in the various subdirectories of [james-rt]/apps/james.
In the directory strings shown below substitute the [james-xxx] entries with the appropriate paths, using the correct OS conventions for slashes and backslashes etc.
The following notes apply to both https://svn.apache.org/repos/asf/james/server/branches/v2.3 and https://svn.apache.org/repos/asf/james/server/trunk as of November 2006.
The goal is to fully use NetBeans for editing, compiling, running, debugging and even profiling James, in "direct" mode (not "attached"). The James project will behave as any other NetBeans IDE Java project, and all the IDE tools and functionalities will be available.
Steps to follow
Create a NetBeans "General Java Application" project ("File>New Project...") as a "Main Project" but without a Main class, and let's call it james-nb in the [james-nb] Project Folder.
- Select "Properties" from the project pop-up menu.
Go to the "Sources" category, click the "Add Folder..." button and select the [james-prj]/src/java folder.
- Go to the "Libraries" category.
- Choose a "Java Platform" (JDK 1.4 and 1.5 are both ok).
In the "Compile" tab click the "Add JAR/Folder" button, navigate to the [james-prj]/lib folder and select all jars.
Again click the "Add JAR/Folder" button and select [james-prj]/phoenix-bin/bin/phoenix-loader.jar.
- Go to the "Run" category.
In the "Main Class" field enter org.apache.avalon.phoenix.launcher.Main. Don't use the "Browse..." button as for some reason the right class will not be shown (probably because "phoenix-loader.jar" has no ".java" classes).
In the "Working Directory" field enter [james-rt]/bin.
- In the "VM Options" field enter (in a single line - no CR):
-Djava.ext.dirs=[james-rt]/lib;[james-rt]/tools/lib -Dphoenix.home=[james-rt] -Djava.security.policy=jar:file:///[james-rt]/bin/phoenix-loader.jar!/META-INF/java.policy
Choose "Build>Build Main Project" from the main menu and a new runnable and debuggable project will be built in the [james-nb]/build and [james-nb]/dist directories.
Now you can either run James choosing "Run>Run Main Project" or debug it choosing "Run>Debug Main Project" from the main menu. It is even possible to profile James if the "NetBeans Profiler" module has been installed.
A few notes
Using the NetBeans IDE as described above is not a substitution for the "standard" James ant scripts when building a working runtime distribution. It is useful for a faster code editing and for debugging etc.
If redoing step 2.b.i above, make sure to fully rebuild the project at the end if changing the "Java Platform" ("Build>Clean and Build Main Project").
In step 2.c.iii, keep in mind that under Windows the [james-rt] entry in the jar:file:///[james-rt] url must use a special convention (see http://www.cs.tut.fi/~jkorpela/fileurl.html) to represent a disk drive: for example C:\james must be entered as jar:file:///C|james.