Writing Netbeans modules in Scala


This is a simple starter guide to setup a new NetBeans Module project which uses the scalac compiler to compile your scala sources, so you can implement your new NetBeans module in the Scala programming language.

For this guide I used the Netbeans IDE 6.9 Beta, but it might be working with former versions as well.

Install the NetBeans Scala Plugin

If not already done, install the Netbeans Scala Plugin. To do so, add the Update Center URL for the Nightly Builds to your update center:


Select and install all scala plugins. More information can be found here: http://wiki.netbeans.org/Scala

Create a new Module project

Goto to File->New Project and select Module under the category “NetBeans Modules“. (If you don‘t see the category you have to install the “Netbeans Plugin Development“ Module first.)

Follow the wizard to create your new project.

Add this stage you have a plain Module project and you could start hacking Java … but we want to hack Scala, so we have to tell NetBeans that it should compile your sources with scalac. This is done in the next step.

Tell NetBeans to use the scala compiler

Since NetBeans uses ant scripts to build projects we can modify them easily.

Open the file “build.xml” in the project root and add the following lines:

Here comes a short explanation:

we override the "jar-excludes" property and append */*.scala as a rule since we don‘t want to have our scala source files included in the jar.

  • “scala.libs“ defines the path to the scala library and compiler jar.
  • with the taskdef we import the scala ant tasks.
  • The modified “compile“ target that uses scalac to compile the sources.

Add the Scala Runtime Library as module dependency.

Goto to the module dependency page of your project and add the “Scala Runtime Library“ as
a dependency.

See it working

Create a new Scala file and write some code. Now “build” your project as usual and you should see a BUILD SUCCESSFUL message on the output screen.

Enjoy hacking your NetBeans module in Scala.


Marco Rico Gomez is a passionate software developer located in Germany who likes to share his thoughts and experiences about software development and technologies with others.

blog comments powered by Disqus