114

I am using Netbeans 6.7. I had first installed Java 1.5 before installing Netbeans. When i installed Netbeans it took Java 1.5 as the default version. Then i installed Java 1.6 on my machine. I need to change the default JDK of my netbeans to 1.6 not only to a specific project but to the whole Netbeans application.

Jan Hrcek
  • 626
  • 11
  • 24
rgksugan
  • 3,521
  • 12
  • 45
  • 53

7 Answers7

215

You can change the JDK for Netbeans by modifying the config file:

  1. Open netbeans.conf file available under etc folder inside the NetBeans installation.
  2. Modify the netbeans_jdkhome variable to point to new JDK path, and then
  3. Restart your Netbeans.
Lucio
  • 4,753
  • 3
  • 48
  • 77
Abdel Raoof Olakara
  • 19,223
  • 11
  • 88
  • 133
  • 2
    For those who already had netbeans_jdkhome with >=7 version. Put the Java EE API library into the Library folder and don't forget to set JDK 7 by right clicking on project and choosing Properties->Sources and set Source/Binary format select JDK7 among options. – Arthur Kushman Feb 08 '14 at 20:39
  • I keep getting error Invalid jdkhome specified --------------------------- Cannot locate java installation in specified jdkhome: C:\Program Files (x86)\Java\jdk1.5.0_03\bin"; Do you want to try to use default version?" – Enthusiastic Nov 06 '15 at 11:54
  • 1
    @Enthusiastic you don't need to include `bin` in the path try like this: `C:\Program Files (x86)\Java\jdk1.5.0_03\` – Abdel Raoof Olakara Nov 07 '15 at 08:47
  • 1
    @AbdelRaoof, gives the same error for that path as well. – Enthusiastic Nov 08 '15 at 15:37
  • 5
    On OSX, I do "cd /Library/Java/JavaVirtualMachines" to find the different JDKs on my Mac. The version I want to use is "/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home". Then at /Applications/NetBeans/NetBeans 7.2.app/Contents/Resources/NetBeans/etc/netbeans.conf, I add this line: `netbeans_jdkhome="/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"` – Raymond Gan Nov 03 '16 at 19:15
34

In my Windows 7 box I found netbeans.conf in <Drive>:\<Program Files folder>\<NetBeans installation folder>\etc . Thanks all.

Paulo Carvalho
  • 554
  • 5
  • 10
32

For anyone on Mac OS X, you can find netbeans.conf here:

/Applications/NetBeans/NetBeans <version>.app/Contents/Resources/NetBeans/etc/netbeans.conf

In case anyone needs to know :)

shousper
  • 1,180
  • 10
  • 12
  • 3
    `netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home"` for example – muttonUp Oct 04 '17 at 15:02
12

open etc folder in netbeans folder then edit the netbeans.conf with notepad and you will find a line like this :

Default location of JDK, can be overridden by using --jdkhome :
netbeans_jdkhome="G:\Program Files\Java\jdk1.6.0_13"

here you can set your jdk version.

Mohamad Alhamoud
  • 4,881
  • 9
  • 33
  • 44
0

on Fedora it is currently impossible to set a new jdk-HOME to some sdk. They designed it such that it will always break. Try --jdkhome [whatever] but in all likelihood it will break and show some cryptic nonsensical error message as usual.

dotbit
  • 4,445
  • 1
  • 7
  • 8
0

Fix this by moving my jdk folder to other disk

JayLord Abueva
  • 393
  • 4
  • 6
0

Either change the jdk home in the application preferences or look for the application's config files.

On Mac OS X, its in a netbeans.conf file, and look for the jdk home value.

here:enter image description here

Michael Coxon
  • 3,337
  • 8
  • 46
  • 68
Towfik Alrazihi
  • 536
  • 3
  • 8
  • 25