DevFaqNetBeansPlatformManager

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/

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.

It took about 25 minutes for the build to finish on my machine.

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.

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 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 A. 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.