Geertjan's Blog

  • October 1, 2007

FreeMarker Fun Pack

Geertjan Wielenga
Product Manager
My nascent interest in FreeMarker has resulted in the 2.0 version of the FreeMarker Plugin that I talked about some days ago. Do the following if FreeMarker is also something that you consider a fun deal:

  1. Download and install the plugin, in 6.0 Beta 1 or some recent 6.0. In the Plugin Manager, you'll see this:

  2. In the New Project wizard, you'll find the sample in the Samples | NetBeans Modules category:

    Finish the wizard shown above.

  3. Now you have a module project. Install it somewhere (either in the current IDE or in some other target NetBeans Platform). Now you have very gentle FreeMarker syntax coloring, code completion, and navigator support for all files with either the "ftl" or "template" extension:

    Note: The first time you call up code completion under Schliemann, per session, it is very slow.

  4. Don't like the colors? That's okay too. Go to the Options window (under the Tools menu) and change the colors:

  5. There are several file templates available, as you can see here:

The most interesting thing to do with this plugin is, assuming you're a developer on the NetBeans Platform who needs to let the user generate code, to look in the layer.xml file. Look at the Templates section, especially the definition of the two wizards. You'll see how a wizard is able to generate from a FreeMarker template, by referencing the template in the URL attribute, in combination with setting the FreeMarker scripting engine element.

The syntax coloring is based on code I found in the NetBeans sources. Until we officially support FreeMarker in the editor, this is the plugin that I will be using. Have fun with it. FreeMarker is really an incredibly cool way to generate code, as my blog entry yesterday went some way to show.

Join the discussion

Comments ( 11 )
  • Markus Tuesday, January 29, 2008

    Hi Geertjan!

    Is the source available for this plugin?

  • tiffany aggas Thursday, February 7, 2008


  • yafengli Tuesday, April 29, 2008

    It does not work in Nebeans 6.1

  • Thomas Sunday, May 25, 2008

    The installation of the plugin (v2) fails in NB 6.1. The following error occurs, if you try to install the downloaded module:

    Networking problem in file:/C:/Users/Administrator/Desktop/1191251262546_org-netbeans-modules-freemarkersupportsample.nbm

  • Geertjan Sunday, May 25, 2008

    Just tried it. It installed without a single problem in 6.1.

  • Thomas Sunday, May 25, 2008

    Probably a Vista problem (UAC is disabled)? A networking problem should not occur with a downloaded module...?! NB 6.1 + JDK 6.0.10

  • Marcus Thursday, August 21, 2008

    Installed in NB 6.1 in Linux Ubuntu and ocurred the same problem as commented at http://blogs.sun.com/geertjan/entry/freemarker_fun_pack#comment-1211729388000 by Thomas, only obviously with the file path diferent.

    Thanks for some solution answer.

  • Geertjan Thursday, August 21, 2008

    Can't help you, because it installs fine for me.

  • hantsy Tuesday, October 13, 2009

    Any updates for this plugin?

    I think this plugin can be split into basic freemarker editor support(for end user, many web frameworks support freemarker as presentation ) and NetBeans Module Template support(for module developer).

    How to embed the freemarker synax into other files , such as jsp, htm, etc?

    Where can I get the latest source code ?

  • Dave Trombley Wednesday, January 18, 2012

    How can we change the colors when we install this in NB 7.1? There is no "text/x-freemarker" option in languages!

  • Geertjan Wednesday, January 18, 2012

    I wrote this in 2007.... so, no, this has not been tried or tested in NetBeans IDE 7.1 and is not going to work.

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