NetBeans 8 new project not working with JDK 9

Netbeans 8 new project doesn't work with Java 9

After installing Java 9 on my Mac, Netbeans 8.2 options to start new project, or open settings, don’t work.

Netbeans 8 new project doesn't work with Java 9

The Problem

Netbeans is using the latest version of Java on my Mac, but I want the IDE itself to use Java 8; which it is more compatible with. I can still develop Java 9 projects, but Netbeans is going to need to start with JRE 8.

List Available Java VMs

On Mac, you can get a list of your available Java VMs with java_home with the -V switch.

~ eric$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
 9.0.4, x86_64: "Java SE 9.0.4" /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
 1.8.0_131, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
 1.8.0_40, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home

I’ve got three VMs installed, two are JDK 8.

Change Netbeans Startup Conf

All I need to do is set Netbeans to use the Java SE 1.8.0_xxx as it’s startup VM.

The netbeans.conf is in the NetBeans app directory. My Netbeans is installed as “NetBeans 8.2” with a space between NetBeans and 8. To use it in a path I have to escape the space with a backslash like “\ “.

This is the path as one line, but the browser will probably wrap it to look like two lines:

/Applications/NetBeans/NetBeans\ 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf 

I also have sublime installed, and I can run it from Terminal with subl like this to edit the NetBeans conf file.

Again, this is one line, but the browser will probably wrap it to look like two lines:

subl /Applications/NetBeans/NetBeans\ 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf 

Look for this, near the end of a default netbeans.conf:

# Default location of JDK:
# (set by installer or commented out if launcher should decide)
#
# It can be overridden on command line by using --jdkhome <dir>
# Be careful when changing jdkhome.
# There are two NetBeans launchers for Windows (32-bit and 64-bit) and
# installer points to one of those in the NetBeans application shortcut 
# based on the Java version selected at installation time.
#
#netbeans_jdkhome="/path/to/jdk"

Remove the comment marker, or # to uncomment the jdk line and change the path to your Java 8 JDK path; something like this (one line):

netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home"

Save it and restart Netbeans.

You should be able to create your new projects and everything else, now.

Netbeans 8 create new project after switching to JDK 8

Boom.

Author: eric

Eric Holsinger is a software professional and photography enthusiast in Southern Maine.