How to specify post-install code in NBM

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

NBM allows to declare its own custom code in NBM archive. This code is called-back by Autoupdate/Updater at the end of installation of NBM into IDE.

     +- Info
     |   |
     |   +--- info.xml
    +- netbeans
        +--- modules...
        +--- <custom code>

If Autoupdate/Updater detects main directory in the NBM archive then descriptor contains information about the own code. Updater runs specified Java code according to these properties.

The properties expected in are:

Property Value


name of the main class, run after module installation from the NBM


classpath elements, may contain more elements


properties for JVM, arguments inserted before the main class name


more arguments for the main class, added after the main class name

The run command is built on top of properties above.

#1 Problem: There was a bug: variable %IDE_USER% contained as same value as %IDE_HOME% i.e. both links to the platform cluster directory and %IDE_HOME% didn’t contain user directory as should be. It was fixed in NetBeans 6.5 platform.

The properties can contain several special variables which Autoupdate replaces by real values:

Variable Value


platform directory


user directory [[1]]


file separator char


path separator char


the current Java home


  • Download and unzip a project

  • Go into samplepostinstall/main directory

  • In main directory is main class Hello which should use most of possibilities of post-install hooks

  • Using properties mainClass, relativeClassPath, jvm.parameters etc.

  • Reads all special variables like %IDE_HOME%, %JAVA_HOME% etc.

  • Opens some GUI

  • Runs a JDK demo

To see that samplepostinstall project in action

  1. download NBM

  2. run NetBeans IDE (6.0 or newer)

  3. invoke Tools|Plugins and switch to Download tab

  4. add the downloaded NBM

  5. install it and then watch post-install hook what will be executed while installing that plugin

I’m not author of this feature, it’s only my investigation.

Do not hesitate to contact me on if you have any question.