Geertjan's Blog

  • November 26, 2011

NetBeans Sources as a Platform

Geertjan Wielenga
Product Manager

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.

Join the discussion

Comments ( 12 )
  • Jirka Monday, November 28, 2011

    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?


  • Jesse Glick Monday, November 28, 2011

    "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 platform-private.properties.

  • idenoq Tuesday, December 27, 2011

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

  • Geertjan Wednesday, December 28, 2011

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

  • Engel Tuesday, January 28, 2014

    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?


  • Geertjan Tuesday, January 28, 2014

    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?

  • Engel Saturday, March 15, 2014

    It possible to use sources located in https://netbeans.org/downloads/zip.html ?

  • Geertjan Sunday, March 16, 2014

    Yes, it possible.

  • Engel Monday, March 17, 2014

    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/CheckModuleConfigs.java:84: 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/CleanAll.java:73: 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.

  • Geertjan Monday, March 17, 2014

    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.

  • Marco Thursday, August 7, 2014

    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


  • rsobies Tuesday, July 26, 2016

    what about maven projects? how to compile ide sources using maven, and then add as dependencies to my maven modules?

    thank you in advance

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.