10 Steps to Happiness with Maven and the NetBeans Platform

If you're interested in Maven and NetBeans IDE, you should definitely read Best Practices for Apache Maven in NetBeans 6.x, by Milos Kleint, the developer of Maven support in NetBeans IDE. There is an incredible amount of tips and tricks in there, from getting started, to deployment, to optimizing your editing experience. It is probably the most important document you will ever find on Maven and NetBeans IDE. Another crucial article is NetBeans Platform Development with Maven 2 by Emilian Bold, although the archetypes used in this blog entry did not exist at the time that Emilian wrote that article. However, everything in that article is of vital importance to you if you are using Maven to create your NetBeans Platform application/s.

Now let's create our first NetBeans Platform application via the tailor-made NetBeans Platform Maven archetype provided by the NetBeans Maven plugin for NetBeans IDE 6.1.

  1. Start NetBeans IDE 6.1 and install the Maven plugin (Tools | Plugins | Available Plugins).

  2. Go to the New Project wizard (Ctrl-Shift-N) and choose Maven | Maven Project and then click Next.

  3. Choose "Maven Netbeans Platform Application Archetype":

    Click Next.

  4. Very important: Don't forget to fill out the details at the bottom of the dialog:

    The 'brandingtoken' and the 'cluster' could be set to anything. The 'brandingtoken' is used during the customization phase of your application, i.e., to distinguish it from other applications. You need to set this here so that you're aware of what the token is later. However, this will not be very important to you (at all) in the greater part of your development process. The 'cluser' determines the name of the folder that will contain your custom modules, i.e., those that are in addition to the clusters of modules provided by the NetBeans Platform. Again, the cluster name is not very important and can be modified later anyway.

    The 'netbeans-install' field is very important. Later, when you run the application, the application will need to know the location of a NetBeans installation. Above, I have set "/home/geertjan/netbeans-6.1" because that is the top level folder of my NetBeans installation.

    Make sure that you press Enter for each of the fields, otherwise the entered text wont't "take" and the wizard will assume that the field is empty, causing problems later when you try to deploy it. There should be default values for all of the above fields; this is a known problem and will be fixed at some point.

  5. Click Finish and observe the two projects in the Projects window. The first is for the application and the second for a dummy module. You can use that module as your starting point and then add more as needed. Here's what you should see:

    There's one small yet very important thing that should be tweaked (again, a known problem). Open the profiles.xml file that you see above. In there, you'll see an element named "netbeans.installation.directory":

    Change that element name to "netbeans.installation". It is a known bug.

  6. Right-click the application and choose Build. It is very important that you do this, because the Run action won't do it for you, so that you'll have deployment problems in the next step if you haven't built the application first.

  7. Now right-click the application and choose Run. This will run the application and you'll see the splash screen of NetBeans IDE 6.1 and then your new application:

    Now, even though our first module doesn't do anything yet, we'll add a second module to our application. To do this, we will need to create our new module in the same folder as where the application is found. Look at step 4 above and notice that we will need to create our new module in "/home/geertjan/NetBeansProjects/DemoRCPApp". OK, let's do it via a new archetype in the next step.

  8. Press Ctrl-Shift-N again and choose Maven | Maven Project | Maven NetBeans Module Archetype:

    Click Next.

  9. Specify the location of the application, as pointed out above:

  10. Click Finish and now you can see that your application consists of two modules (in addition to the modules that the NetBeans Platform makes available):

Now refer to the two articles at the start of this blog entry which, together, should give you everything you need when working with Maven and the NetBeans Platform.


that very intersting!

Posted by fiony on May 23, 2008 at 06:58 AM PDT #

Thanks a lot. REally, interesting.

Posted by Blogumdan on May 30, 2008 at 07:23 AM PDT #

fine thenks

Posted by mirc on September 23, 2008 at 08:19 PM PDT #

Hi Geertjan,

have the following problems to run a rcp project in Netbeans 6.1 and Netbeans 6.5 under the given tutorial. I can't find the reason to resolve this.
I hope you can help me.

Thanks a lot,

NetBeans: Executing 'mvn.bat -Pnetbeans-location nbm:cluster nbm:run-platform'
NetBeans: JAVA_HOME =C:\\Programme\\Java\\jdk1.6.0_10
Scanning for projects...
Searching repository for plugin with prefix: 'nbm'.
Building DemoRCPApp - NetBeans Platform Application
task-segment: [nbm:cluster, nbm:run-platform] (aggregator-style)
Created NetBeans module cluster(s) at C:\\Dokumente und Einstellungen\\User\\Desktop\\NetBeansProject\\DemoRCPApp - NetBeans Platform Application (pom)\\target/netbeans_clusters
Executing: "C:\\Programme\\NetBeans 6.5\\platform9\\lib\\nbexec.exe" --userdir '"C:\\Dokumente und Einstellungen\\User\\Desktop\\NetBeansProject\\DemoRCPApp - NetBeans Platform Application (pom)\\target\\userdir"' -J-Dnetbeans.logger.console=true -J-ea --branding demotoken --clusters '"C:\\Dokumente und Einstellungen\\User\\Desktop\\NetBeansProject\\DemoRCPApp - NetBeans Platform Application (pom)\\target\\netbeans_clusters\\rcpapp"'
Der Befehl "C:\\Programme\\NetBeans" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Total time: 2 seconds
Finished at: Thu Dec 11 12:58:29 CET 2008
Final Memory: 2M/5M

Posted by Danny on December 10, 2008 at 08:12 PM PST #


Posted by mırc on February 13, 2009 at 05:36 PM PST #

Hi Geertjan,

Thanks for this blog entry. In the current Module for 6.5 you need to do a little trik to get the Run Action to work:

Cheers Toni

Posted by Toni Epple on February 24, 2009 at 07:42 PM PST #


Posted by Cody on March 27, 2009 at 07:09 AM PDT #

Hi Geertjan.

Thanks for this excellent information. Perhaps it's time for an updated version of this article.

Using the 1.1 archetypes for applications and modules, I was able to avoid the need to define the three additional properties in the wizard. Perhaps you could include that in an updated article. Hopefully the 1.0.2 archetypes will soon get ditched in the maven netbeans archetype list.


Posted by Steve Taylor on March 28, 2009 at 01:29 AM PDT #

It would be nice to see a follow-up article, perhaps explaining things like how to get NB platform components onto the palette so they can be used in the GUI builder.

Posted by Steve Taylor on March 28, 2009 at 01:55 AM PDT #

ERROR]Mojo (aggregator):
[ERROR] org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-3:generate
[ERROR]FAILED while executing in directory:
[ERROR] /home/wilfredo/NetBeansProjects
[ERROR]Archetype org.codehaus.mojo.archetypes:netbeans-platform-app-archetype:1.0.2 is not configured
[ERROR]Error stacktrace:
[ERROR]org.apache.maven.AggregatedBuildFailureException: Build in root directory: /home/wilfredo/NetBeansProjects failed during execution of aggregator mojo: org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-3:generate
[ERROR] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:279)
[ERROR] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:180)
[ERROR] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:149)
[ERROR] at org.netbeans.modules.maven.embedder.exec.MyLifecycleExecutor.execute(MyLifecycleExecutor.java:94)
[ERROR] at org.apache.maven.DefaultMaven.execute_aroundBody0(DefaultMaven.java:223)
[ERROR] at org.apache.maven.DefaultMaven.execute_aroundBody1$advice(DefaultMaven.java:304)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:1)
[ERROR] at org.apache.maven.embedder.MavenEmbedder.execute_aroundBody2(MavenEmbedder.java:904)
[ERROR] at org.apache.maven.embedder.MavenEmbedder.execute_aroundBody3$advice(MavenEmbedder.java:304)
[ERROR] at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:1)
[ERROR] at org.netbeans.modules.maven.execute.MavenJavaExecutor.run(MavenJavaExecutor.java:233)
[ERROR] at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
[ERROR]Caused by: org.apache.maven.plugin.MojoFailureException: Archetype org.codehaus.mojo.archetypes:netbeans-platform-app-archetype:1.0.2 is not configured
[ERROR] at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:202)
[ERROR] at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:579)
[ERROR] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:498)
[ERROR] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:265)
[ERROR] ... 11 more

Posted by guest on May 08, 2009 at 03:21 PM PDT #

Thanks a lot for the tutorial. I was previously using non maven Application platform project, and I ran into a big problem with Wrapper modules and dependencies. So I switched to maven and things seems a lot better. However, I have a problem now that in a module where I have set dependencies to my api, it takes ages for maven to build this module(roughly 5-6 minutes)
NBM Plugin generates manifest
Adding on module's Class-Path:
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
skip non existing resourceDirectory C:\\Users\\mgone\\Documents\\NetBeansProjects\\WorkflowFrontend\\TransformersView\\src\\test\\resources
Not compiling test sources
Tests are skipped.
Adding existing MANIFEST to archive. Found under: C:\\Users\\mgone\\Documents\\NetBeansProjects\\WorkflowFrontend\\TransformersView\\target\\classes\\META-INF\\MANIFEST.MF
Building jar: C:\\Users\\mgone\\Documents\\NetBeansProjects\\WorkflowFrontend\\TransformersView\\target\\TransformersView-1.0-SNAPSHOT.jar
Copying module jar to C:\\Users\\mgone\\Documents\\NetBeansProjects\\WorkflowFrontend\\TransformersView\\target\\nbm\\netbeans\\foobar\\modules
[WARNING] Cannot find license file at C:\\Users\\mgone\\Documents\\NetBeansProjects\\WorkflowFrontend\\TransformersView\\license.txt
[WARNING] You don't define distributionUrl parameter in the nbm-maven-plugin configuration. That's ok for local installation but f you want to create an autoupdate site, you have to define this property.
[WARNING] Using default value for distribution URL: null
Installing C:\\Users\\mgone\\Documents\\NetBeansProjects\\WorkflowFrontend\\TransformersView\\target\\TransformersView-1.0-SNAPSHOT.jar to C:\\Users\\mgone\\.m2\\repository\\eu\\esdihumboldt\\TransformersView\\1.0-SNAPSHOT\\TransformersView-1.0-SNAPSHOT.jar
Installing C:\\Users\\mgone\\Documents\\NetBeansProjects\\WorkflowFrontend\\TransformersView\\target\\TransformersView-1.0-SNAPSHOT.nbm to C:\\Users\\mgone\\.m2\\repository\\eu\\esdihumboldt\\TransformersView\\1.0-SNAPSHOT\\TransformersView-1.0-SNAPSHOT.nbm
Total time: 5 minutes 33 seconds
Finished at: Wed Jun 17 10:20:51 CEST 2009
Final Memory: 21M/52M

This is really annoying, how can I fix this? I dont even know where the problem is.


Posted by Moses Gone on June 16, 2009 at 06:25 PM PDT #

Hi Geertjan,
I do like the maven+NetBeans platform combo and I welcomed the new features in 6.9M1 for example one from File>New Project>Maven>Maven NetBeans module

I tought I'll try but no luck because

The desired archetype does not exist (org.codehaus.mojo.archetypes:nbm-archetype:1.3-SNAPSHOT)
Do you think I should fill in a bug for this or just wait till someone deploys it
Do you happen to know a rep where I can get org/codehaus/mojo/archetypes/nbm-archetype/1.3-SNAPSHOT/nbm-archetype-1.3-SNAPSHOT.jar ?
kind regards,

Posted by Zoltán Baráti on February 16, 2010 at 08:42 PM PST #

Do you have an updated set of instructions for 7.0.1 netbeans. I don't see some of the screens the same way as posted.


Posted by Narayan on December 09, 2011 at 04:32 AM PST #

Can you give a small clue which screens you're talking about?

Posted by Geertjan on December 09, 2011 at 04:50 AM PST #

Sorry I wasn't clear about the screens. I am using Maven 7.0.1.

To create a module suite which consists of list of netbeans modules that will be portable to eclipse,
I assume I have create Netbeans Module suite. Correct me if I am wrong. My module suite has bunch of netbeans modules under it. I don't even see the screen in step 4.

Please advice on direction to take.

Posted by Narayan on December 12, 2011 at 04:50 AM PST #

Maven 7.0.1? Are you sure? Maven is at version 3 at the moment, I believe. And who said anything anywhere about "NetBeans modules that will be portable to Eclipse"? And where in the steps above do you see anything about a Netbeans Module suite? Sorry, can't help you, nothing you've said makes sense. Maybe write to the mailing list (dev@platform.netbeans.org) and see if someone can help you there.

Posted by guest on December 12, 2011 at 05:16 AM PST #

Sorry for the typo. I meant netbeans 7.0.1

Posted by Narayan on December 13, 2011 at 02:20 AM PST #

This blog entry was written in 2008... so why not use the official tutorial instead on the official tutorial site:


Posted by Geertjan on December 13, 2011 at 02:46 PM PST #

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.


« September 2016