How to Fix the “Invalid jdkhome” Error Message on NetBeans Load Tips, Tricks and Tutorials 16 OCT 2014

For NetBeans IDE users: Whenever you upgrade/downgrade your JAVA installation, more often than not you will encounter an error message when firing up NetBeans that essentially complains about not being able to locate the JAVA installation in the specified jdkhome variable:

netbeans invalid jdkhome specified error screenshot

(Note, selecting the Yes option will work 9 out of 10 times, unless of course you have completely uninstalled JAVA from your system).

It turns out that to fix this invalid jdkhome error is pretty easy. First, navigate to your NetBeans installation folder which by default should be “C:\Program Files\NetBeans 8.0” and look for the folder “etc”. Inside that folder should be a file with the name “netbeans.conf”. What you need to do is to open the file with your favorite text reader (notepad as an example) and look for the line that starts with netbeans_jdkhome=.

IMPORTANT: You might need administrative rights to save changes to this file. In that case, first open your text editor by right-clicking on the text editor icon and selecting the Run as Administrator option. (This is assuming that you are using Windows)

The next step is to alter the line to point to the currently installed JAVA JDK version. It should look something like this netbeans_jdkhome=”C:\Program Files\Java\jdk1.8.0_20″. If you are unsure as to which JDK version you currently have installed, navigate to your java’s installation folder (the default path is C:\Program Files\Java) and look for relevant JDK folder there.

Save the changes, and restart NetBeans.

edit netbeans.conf to fix jdkhome error

Simple as that.

Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.

  • Thierry Randriantiana

    Thank you ! That made my day.

  • Thanks. Glad to get rid of that nagging message.

  • Kevin Rahe

    This tip doesn’t work with NetBeans 8.2 on either of my two 64-bit Windows 7 boxes. I change the jdkhome in netbeans.conf, but netbeans64.exe still looks for the version of Java that NetBeans was configured for when it was first installed (in my case 1.8.0_121, which I’m trying to replace with 1.8.0_131). I’ve searched all the files in the NetBeans directory as well as the registry, and cannot find any reference to the previous version. I’m beginning to think that the JDK version/location is hard-coded into the exe when NB is installed, which can only be changed by reinstalling it.

    • ToFew

      make sure NB isn’t running while editing .conf file;
      just comment-out the line altogether to let the launcher find the installed jdk, per documentation:

      # Default location of JDK:
      # (set by installer or commented out if launcher should decide)
      #
      # It can be overridden on command line by using –jdkhome
      # 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=”C:Program FilesJavaserver-jre-8u102-windows-x64jdk1.8.0_102″

      Worked for me, but also check that you don’t have multiple NB installations, i.e., “Program Files (x86)” vs “Program Files”

      • Kevin Rahe

        Actually, the problem turned out to be that while it appeared I was editing the one and only netbeans.conf file, whenever I saved it UAC was actually saving a copy to a separate folder tied to my user ID. When I would run NetBeans, however, instead of reading that copy it would read the original – unchanged – version. The only way to edit the version of the file actually being used by NetBeans is to use “Run as administrator” to start my text editor. Pretty maddening.

        • ToFew

          ewww – what text editor are you using that triggers UAC virtualization? on my machine notepad++ prompts for priv elevation, invoking UAC dialog as needed, whenever I attempt to save outside my user’s permission.. I initially thought you issue could have been some user-environment problem instead of program compatibility (or a possible installer bug), but I’m glad you worked it out and shed light on this!

          ~cheers!