NetBeans Sources as a Platform

By default, when you create a new NetBeans module, the 'development IDE' is the platform to which you'll be deploying your module. It's a good idea to create your own platform and check that into your own repo, so that everyone working on your project will be able to work with a standardized platform, rather than whatever happens to be beneath the development IDE your using.

Something else you can do is use the NetBeans sources as your platform, once you've checked them out. That's something I did the other day when trying to see whether adding 'setActivatedNodes' to NbSheet was sufficient for getting UndoRedo enabled in the Properties Window. So that's a good use case, i.e., you'd like to change the NetBeans Platform somehow, or you're fixing a bug, in other words, in some way you need to change the NetBeans Platform sources and then would like to try out the result of your changes as a client of your changes.

In that scenario, here's how to set up and use a NetBeans Platform from the NetBeans sources.

  1. Run 'ant -Dcluster.config=platform build-platform' on the root of the NetBeans sources. In about two minutes, you'll end up with nbbuild/netbeans containing a subfolder 'platform' and a subfolder 'harness'. There's your NetBeans Platform.

  2. Go to Tools | NetBeans Platform and browse to 'nbbuild/netbeans', registering it as your NetBeans Platform.

  3. Create a new NetBeans module, using the new NetBeans Platform as the platform.

  4. Now the cool thing is you can open any of the NetBeans modules from the NetBeans Platform modules in the NetBeans sources. When you change the source code of one of these modules and then build that module, the changed JAR will automatically be added to the right place in the nbbuild/netbeans folder. And when you do a 'clean' on a NetBeans Platform module, the related JAR will be removed from nbbuild/netbeans.
In other words, in this way, by changing the NetBeans sources, you're directly changing the platform that your custom module will be running on when you deploy it. That's pretty cool and gives you a more connected relationship to your platform, since you're able to change it in the same way as the custom modules you create.

I wonder what is the proper way of integrating the platform into the rest of the project

1) How about the versioning? The platform is in Hg, but often one needs to use another versioning system for the app (we use svn). If I used the same system, I would probably mark the platform as external dependency, but what to do when I do not use the same system? (I can imagine checking it out, copying to my svn, and then do some synchronization when the original checked-out copy updates).

2) Is it somewhere described how it is with platform updates in Hg? When I use the platform provided by the IDE, I get the updates of the platform for free once they are released. I can simply point my app to the NB update center, or download the modules from there and adding them to my UC.
If I use my own copy of the platform, I probably check out some stable branch/tag and then I should migrate it to another branch/tag, once an update was released, or not?


Posted by Jirka on November 27, 2011 at 10:21 PM PST #

"create your own platform and check that into your own repo" - the third way, recommended for most users, is to make the app depend on a named release of the NB Platform. That is supported in NB 7.1 without the need to check the platform binaries into source control; the requested platform modules are downloaded from an update center on demand. See harness/README for details (not yet offered as a GUI option).

If you do this, of course you cannot use your own patched version of the platform. But if you want to experiment with a patch - an API change or a bug fix - without changing the project's official build, you can temporarily switch platforms in

Posted by Jesse Glick on November 28, 2011 at 04:36 AM PST #

I have checked everything using mercurial, built using ant and added platform to NB. Everything is working perfectly but it is missing "Project API" and "Project UI API" in libraries which I need to compile into the module I am trying to build. Do you have any clue what might be wrong? I have searched web and couldn't find answer...

Posted by idenoq on December 27, 2011 at 01:01 PM PST #

Those modules are not part of the NetBeans Platform. They are part of NetBeans IDE.

Posted by Geertjan on December 27, 2011 at 05:20 PM PST #

Is there a way to get the nbuild of certain module instead of the entire platform? I need to change autoupdate.ui module but I can't download the entiry repository.
So, It's posible to do this?


Posted by Engel on January 27, 2014 at 09:14 PM PST #

I think Mercurial lets you point to a specific subfolder, so, you don't need to download a whole repo, just a folder within it. What do you need to change?

Posted by Geertjan on January 28, 2014 at 12:20 AM PST #

It possible to use sources located in ?

Posted by Engel on March 14, 2014 at 07:30 PM PDT #

Yes, it possible.

Posted by Geertjan on March 16, 2014 at 09:40 AM PDT #

I did try but it throws a lot of errors. This is the output:

engel@Hyperlion:~/Documents/NBPlatform/src/platform/nbp-custom$ ant -Dcluster.config=platform build-platform
Buildfile: /home/engel/Documents/NBPlatform/src/platform/nbp-custom/build.xml









[echo] Bootstrapping NetBeans-specific Ant extensions...
[javac] Compiling 70 source files to /home/engel/Documents/NBPlatform/src/platform/nbp-custom/nbbuild/build/antclasses
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] /home/engel/Documents/NBPlatform/src/platform/nbp-custom/nbbuild/antsrc/org/netbeans/nbbuild/ error: incompatible types
[javac] Map<String,String> properties = getProject().getProperties();
[javac] ^
[javac] required: Map<String,String>
[javac] found: Hashtable<String,Object>
[javac] /home/engel/Documents/NBPlatform/src/platform/nbp-custom/nbbuild/antsrc/org/netbeans/nbbuild/ warning: [rawtypes] found raw type: Hashtable
[javac] private Hashtable targets;
[javac] ^

[javac] E extends Object declared in interface Set
[javac] 10 errors
[javac] 64 warnings

/home/engel/Documents/NBPlatform/src/platform/nbp-custom/nbbuild/build.xml:397: The following error occurred while executing this line:
/home/engel/Documents/NBPlatform/src/platform/nbp-custom/nbbuild/build.xml:105: Compile failed; see the compiler error output for details.

Posted by Engel on March 17, 2014 at 01:57 PM PDT #

Yeah, sorry, not going to be debugging your problems in my blog and next time you post a stack trace here, I'll delete it. Use the NetBeans Platform mailing list instead.

Posted by Geertjan on March 17, 2014 at 02:00 PM PDT #

Hi Geertjan,
I have all the source code, I launch the command
ant -f nbbuild -Dcluster.config=platform build-platform
but then I in the platform there is no JUnit module and no way to use the module NbJUnit in the harness.
Do you have any idea? To solve the issue I had to add it manually

Posted by Marco on August 07, 2014 at 07:33 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« June 2016