[java] How to set the JDK Netbeans runs on?

I have older NB6.7, NB6.9, NB7.0, which used to run on jdk1.6.0_21 and jdk1.6.0_25. Now I've removed those JDKs and only have jdk1.6.0_26 and jdk1.7.0 left, but I still want to keep the older NBs, but now when I run them, I get this message:

"Cannot locate java installation in specified jdkhome C:\Program Files (x86)\Java\jdk1.6.0_25 Do you want to try to use default version ?"

I tried to find where it's looking for the "jdk1.6.0_25", and updated a few config files in "C:\Program Files (x86)\NetBeans 6.7" and "C:\Users\USER.nbi\registry.xml", and yet the message keeps coming, my question is, where and what do I need to change to point it to: C:\Program Files (x86)\Java\jdk1.6.0_26?

This question is related to java netbeans

The answer is


As a further useful solution for those of you on Windows 7 and above - if you use:

C:\Program Files\Java>mklink /D jdk8 jdk1.8.0_25

you get a Symbolic Link folder that can be adjusted whenever a new JDK comes out.

All you need to do then is set your

netbeans_jdkhome="C:\Program Files\Java\jdk8"

(in both locations for Netbeans 8) and you never have to edit the config again. Just tweak the symlink each time your JDK is updated.


It does not exactly answer your question, but to get around the problem,

  1. you can either create a .cmd file with following content:

    start netbeans --jdkhome c:\path\to\jdk

  2. or in the shortcut of Netbeans set the above option.


Go to Tools -> Java Platforms. There, click on Add Platform, point it to C:\Program Files (x86)\Java\jdk1.6.0_25. You can either set the another JDK version or remove existing versions.

Another solution suggested in the oracle (sun) site is,

netbeans.exe --jdkhome "C:\Program Files\jdk1.6.0_20"

I tried this on 6.9.1. You may change the JDK per project as well. You need to set the available JDKs via Java Platforms dialog. Then, go to Run -> Set Project Configuration -> Customize. After that, in the opened Dialog box go to Build -> Compile. Set the version.


All the other answers have described how to explicitly specify the location of the java platform, which is fine if you really want to use a specific version of java. However, if you just want to use the most up-to-date version of jdk, and you have that installed in a "normal" place for your operating system, then the best solution is to NOT specify a jdk location. Instead, let the Netbeans launcher search for jdk every time you start it up.

To do this, do not specify jdkhome on the command line, and comment out the line setting netbeans_jdkhome variable in any netbeans.conf files. (See other answers for where to look for these files.)

If you do this, when you install a new version of java, your netbeans will automagically use it. In most cases, that's probably exactly what you want.


Where you already have a project in NetBeans and you wish to change the compiler (e.g. from 1.7 to 1.) then you would need to also change the Java source compiler for that project.

Right-click on the project and choose properties as outlined below:

Java Project Properties

Then check that the project has the necessary source circled below:

Project Source Compiler

then check that the Java compiler is correct for the project:

enter image description here


For those not using Windows the file to change is netbeans-8.0/etc/netbeans.conf

and the line(s) to change is:

netbeans_jdkhome="/usr/lib/jvm/java-8-oracle"

commenting out the old value and inserting the new value


I had this message too because today i decided to relocate my different jdk in the same directory. I have decided to uninstall all through program manager of window. After that, of course i had the message below.

"Cannot locate java installation in specified jdkhome C:\Program Files (x86)\Java\jdk1.7.0_60 Do you want to try to use default version ?"

A new install of the jdk does not resolve the problem. Ok you can configure that in menu Tool > java platforms but in my case i had to fix my netbeans.conf

i had the line below

netbeans_jdkhome="C:\Program Files\Java\jdk1.7.0_60"

and i replace it by

netbeans_jdkhome="C:\devtools\Java\jdk1.8.0_25"

IN windows open cmd

go to directory where your netbeans downloaded

then run below command JDK path may be different from the path I mentioned

netbeans-8.2-windows.exe --javahome "C:\Program Files\Java\jdk-9.0.1"

if you face issue in existing installed in netbeans you can find details in here