How do I set up a NetBeans Platform in the IDE ?
By default, a NetBeans Platform application will use the developer’s copy of the IDE as the platform. This is certainly easy, but there are also drawbacks to using the current IDE as a platform. With that in mind, lets check out, and reference our own copy of the NetBeans source code. This way we can also use breakpoints to step through the NetBeans source code, make changes, and create patches!
At a high level the steps are as follows. First get the NetBeans source code checked out. This part is interesting because what you end up with is a complete copy of the NetBeans source repository on your local file system. The second thing you need to do is build the NetBeans platform using the source repository that you just checked out. This is important because without building the platform you will not have the dependencies required by the platform modules. The next step is to create a new platform reference. Of course the platform to reference will be the one that you just checked out and built. Then finally, in your module suite’s project properties, select the platform reference that you just created.
So, in more detail then…
1. Check Out NetBeans Source Code
First get the source code from the Mercurial repository. In the following example the source code is checked out to a local ~/netbeans-repository/ directory. In this example the tilde is used to represent the home directory of your file system.
So far, so good, but you still need to build the source code so that you have a complete NetBeans Platform, along with all the jar dependencies.
2. Build The NetBeans Source
Building the NetBeans source is very easy, and very satisfying to watch! Just open up your favorite terminal client and navigate to your local repository.
cd ~/netbeans-repository/main/
Set the available memory that Ant can use:
set ANT_OPTS=-Xmx256M
(or on Unix, export ANT_OPTS=-Xmx256M
)
Then simply run ant.
ant -Dpermit.jdk6.builds=true
Note, I am choosing to build NetBeans using JDK1.6 so I have to explicitly tell NetBeans that I understand that only JDK1.5 is supported. As of NetBeans 6.9, NetBeans is built with JDK 6, and this flag is no longer needed.
3. Create A New Platform Reference In NetBeans
In order to work with the NetBeans platform that you just built it needs to be added as a platform in the IDE.
-
Click Tools → NetBeans Platforms (note that the menu item name varies slightly in older versions)
-
Click the "Add Platform…" button in the lower right
-
Locate the platform binary and click OK. In this example the proper path is ~/netbeans-repository/main/nbbuild/netbeans/.
-
You can associate sources and javadoc for this platform using the respective tabs in the platform manager
-
You can also choose which version of the build scripts you want to us on the Harness tab. You’ll usually want to use the version corresponding to that platform.
4. Reference The New NetBeans Platform
Now just select the platform in your module suite’s Project Properties. There you will see a Netbeans Platform dropdown box where you can select the platform that you set up.
Note: I did have to go through and resolve some of the cluster dependencies. That just means that I had to check the dependencies that Netbeans said that other modules needed. Once you get this far it will be very obvious what to do.
Appendix: NetBeans Platform And Using JDK1.6
In order to use JDK1.6 with the Netbeans source code we need to tell the Netbeans platform that we understand that only JDK1.5 is supported. What you need to do is create a "user.build.properties" file and put it in the nbbuild directory.
touch ~/netbeans-repository/main/nbbuild/user.build.properties
Inside the user.build.properties file put the following line.
permit.jdk6.builds=true
_This tutorial applies to: versions 6.7 and earlier of the NetBeans Java IDE. _