Over a million developers have joined DZone.

Hack Your Own Custom NetBeans Project Templates

DZone's Guide to

Hack Your Own Custom NetBeans Project Templates

· Java Zone ·
Free Resource

The CMS developers love. Open Source, API-first and Enterprise-grade. Try BloomReach CMS for free.

Somebody recently asked in a forum how he could turn NetBeans projects into project templates. Say, you want to start a series of projects with the same properties and classes, or maybe you want to pass on a well-working custom setup to colleagues.

There must be a more elegant way than copying a project directory and then refactoring it? Turns out there is: The Help menu quickly informs me to use the Project Template wizard. (Mental note to self: Look into Help menu more often.) Not only can you create custom project templates, you can even distribute and install them as easy as plugins! :D This is how:

  1. Create the project that you want to be the template, and open it in NetBeans. The template project can include properties, classes, resources, an Ant script... — whatever you need.
  2. Here's the thing: Create a new empty NetBeans Module project. Right-click the module project and create a Project Template file (New > Other > Module Development > Project Template):

    Click Next and point the Project Template wizard to the template project and assign a category, like "Java EE" or "Samples".

  3. Right-click the module project and select "Install in Development IDE". Your project template is added to the New Project dialog, in the category you assigned earlier.

Tip: Right-click the module project and select Create NBM. The template is saved as an NBM file to the module project's build directory. This way you can distribute and install your custom template like a plugin, using the Plugins Manager.

You can find a more detailed version of how to create your own project templates in my blog. Geertjan goes into even more detail in his related article about how to add Custom Project Samples. He shows you how to add a custom icon and a description, and even how to hack the New Project wizard and add new panels to it — check it out!

BloomReach CMS: the API-first CMS of the future. Open-source & enterprise-grade. - As a Java developer, you will feel at home using Maven builds and your favorite IDE (e.g. Eclipse or IntelliJ) and continuous integration server (e.g. Jenkins). Manage your Java objects using Spring Framework, write your templates in JSP or Freemarker. Try for free.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}