Compiling Saxonb9j using NetBeans
This page describes the creation of a project to build Saxon-bj 22.214.171.124 with NetBeans 6.0. (In fact, a beta build of NetBeans 6.0.1.)
I will assume that you have downloaded and installed NetBeans 6.0 (or 6.0.1).
You will also need:
- a recent Ant jar file
- a recent JDOM jar file
- a recent dom4j jar file
- a recent XOM jar file
To obtain an ant binary distribution, go to http://ant.apache.org/, and select Binary Distributions from the Download menu in the left-side navigation menu. Select the latest zip file, and download. Unzip the file to a convenient location. You will need ant.jar from the lib directory. The distribution version as of writing is 1.7.0.
To obtain a JDOM binary, go to http://www.jdom.org/, and select Binaries from the Downloads item in the left-side navigation menu. From Release Builds, select the link to the latest (or only). Download the zip file. Unzip the file to a convenient location. You will need jdom.jar from the build directory. The distribution version as of writing is 1.1.
To obtain a dom4j binary, go to http://www.dom4j.org/, and select Download from the menu in the left-side navigation menu. Under Download the current release, follow the link to SourceForge. Scroll down to the File Releases section, and select the latest jar file. Download. The distribution version as of writing is 1.6.1.
To obtain an XOM binary, go to http://www.xom.nu/.(or here) From the Downloads item on the right-side navigation menu, select Minimal JAR file. Download. The distribution version as of writing is 1.1.
Open NetBeans. Open the checkout dialogue.
Select [https:// https://] from the Repository URL: dropdown list, and enter https://saxon.svn.sourceforge.net/svnroot/saxon as the repository URL. Leave the User and Password blank for anonymous access. Set you proxy configuration as required. (I have none from home.) Click Next>.
Open the latest9.0 folder. Select the bj folder. Click OK. This returns you to the Checkout>Folders to Checkout dialogue, with the repository folder as selected.
Leave the Repository Revision field blank. If you are happy to have a bj subdirectory under your selected Local Folder, leave the Skip "bj" and checkout only its contents box clear. If you want to fully specify the destination Local Folder, tick Skip "bj" etc. However, you will need one directory at the top level, that is, at the same level as bj, in your project. Enter or browse to the Local Folder you will use as a working directory. There are no NetBeans projects defined in the sources, so leave the Scan for Netbeans Projects after Checkout box clear. Click Finish. The status bar (bottom right) shows the progress of the checkout.
This brings up the New Project dialogue.
Select Java from Categories: and Java Project with Existing Sources from Projects: which brings up the New Java Project with Existing Sources dialogue.
Enter a project name, e.g. saxon-b9j, and browse to the newly checked-out project sources. Click Next>. This brings up the empty Existing Sources dialogue. Beside the empty Source Package Folders display area, click Add Folder. The Browse Source Packages Folder dialogue appears.
Browse to the newly checked-out saxon sources, and select the folder above the net folder; in this case, bj. Click Open. In the Existing Source's dialogue, click Next>. The Incudes & Excludes dialogue displays, with all files selected in the Includes:.
In the Excludes: field, enter **/dotnet/. Click Finish. The project is created and opened, with a node in the Projects window. Open this project node, then open the Libraries node under it. Right-click Libraries, and select Add JAR/Folder...
Navigate to the jar files you have previously downloaded, and add each of them in this manner.
Notice the error flags on the project node and the Source Packages node. Open the Source Packages node.
This shows errors in two packages: net.sf.saxon and net.sf.saxon.s9api. Open the net.sf.saxon node.
The error is in Configuration.java. Double-click to open this file.
Notice the comments /*DOTNETONLY*/ and /*JAVAONLY*/. This comments are used by the Saxon build system to make changes to the source files depending on the target of the build. Notice also that the import of net.sf.saxon.dotnet.DotNetPlatform, which has been commented out at the top of the imports, has been reinstated further down, and is in error, due to the absence of the net.sf.dotnet package.
Comment out this import.
All instances of the comment /*DOTNETONLY*/ must be replaced the the comment leader .
Click Replace All.
Save the file with Ctrl-S. The error markers will be cleared from the editor window, but may not clear from the Projects window until another file has editor focus.
Return to the Projects window, and open the net.sf.saxon.s9api node. The file in error is SchemaManager.java. Double-click to open this file.
Three imports are in error. These imports are from Saxon proprietary files. Comment these imports out. New errors will appear, where these classes are referenced. Scroll down to where the red error bars occur on the right of the editor pane. The errors occur in two methods:// importComponents and exportComponents. Comment these methods out.
The error markers in the editor will disappear. Again, the Projects window error markers may not disappear until another file gains focus. Once this has happened, the project will be free of errors.
Right-click on the project node in the Projects window. Click on Properties.
Check the Encoding: value. (This may only be available on NetBeans 6.0.1.) If it is not windows-1252, select this value from the drop-down menu.
Build the project. If everything has gone according to plan, the output will be like this.
Note the location of the jar file, specified in the output.