Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Apache NetBeans and Scala

DZone's Guide to

Apache NetBeans and Scala

Let's get you generating Scala projects in Apache NetBeans! While NetBeans is still incubating, here are the steps to get the necessary foundations set.

· Java Zone ·
Free Resource

Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.

Whilst NetBeans is incubating, getting the venerable NetBeans Scala Plugin into the IDE running JDK 9 and above is a bit of a trial.

NetBeans is in the incubator, and the Maven artifacts are not being published. What coordinate would they be published under? That is one for another day and involves beer (or your preferred tipple)!

Anyway, for the moment, we have to do a little work to get Scala running on the bleeding edge version of NetBeans. I am going to make the assumption, for brevity, that you have cloned NetBeans.

Firstly, there are a few things we need to clone:

  1. NetBeans from the incubator

  2. nb-repository-plugin from codehaus.
  3. nbscala

You'll also need JDK8 installed — I get a bit cross with all the advice on how to manage Java versions on a Mac (I'm afraid it can't speak to Windows), but ultimately, you'll need to ensure that you have your Java Home set to JDK8. I might write a post about this topic soon because it is just not as complex as some like to make out.

Guess what, we need to build NetBeans. This will take a while, but you get a shiny new version of NetBeans to play with, including JDK10 support. Next, build the nb-repository-plugin. This gets us version 1.4-SNAPSHOT, which includes maven support 3.5.x+.

Next, let's point the nbscala to all these new things. Open up the pom.xml of the parent project  and look for the following two properties:

<nb.installation></nb.installation>
<nb.nbmdirectory></nb.nbmdirectory>


Set the installation property to the NetBeans directory of the one you just built. Don't worry about the nbmdirectory just yet, but most likely it will be the ${projectdir}/target/nbms.

So the next thing is to install all the NetBeans-generated JARs into our the local Maven repository.

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home M2_HOME=/usr/local/Cellar/maven/3.5.3/libexec /usr/local/Cellar/maven/3.5.3/libexec/bin/mvn org.codehaus.mojo:nb-repository-plugin:1.4-SNAPSHOT:populate


Last step before the fun. Build the nbscala plugins.

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home M2_HOME=/usr/local/Cellar/maven/3.5.3/libexec /usr/local/Cellar/maven/3.5.3/libexec/bin/mvn clean install


Once this is done, we get to install the plugins to our new NetBeans installation. All the nbms and JARs you need are in the target directory, 22 in all!!

If everything has gone to plan, you can now generate Scala projects in Apache NetBeans.

Connect any Java based application to your SaaS data.  Over 100+ Java-based data source connectors.

Topics:
java ,scala ,apache netbeans ,tutorial

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}