I have just installed Netbeans 8.0.2 on CentOS 6.5.
When I try to run it, I get the message
Cannot find java. Please use the --jdkhome switch
I have /usr/share/java-1.7.0 so I typed
/usr/local/netbeans-8.0.2/bin/netbeans --jdkhome /usr/share/java-1.7.0
and still got
Cannot find java. Please use the --jdkhome switch
I also have /root/Downloads/jdk1.8.0_40 which allowed me to install Netbeans. However, when I type
/usr/local/netbeans-8.0.2/bin/netbeans --jdkhome /root/Downloads/jdk1.8.0_40
I still get
Cannot find java. Please use the --jdkhome switch
I tried
whereis java
and got
java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz
However
/usr/local/netbeans-8.0.2/bin/netbeans --jdkhome /usr/bin/java
still produces
Cannot find java. Please use the --jdkhome switch.
In my case, I had installed *ahem* OpenJDK, but the bin folder was full of symlinks to the bundled JRE and the actual JDK was nowhere to be found.
When I see a directory structure with bin
and jre
subdirectories I expect this to be the JDK installation, because JRE installations on Windows looked different. But in this case it was the JRE installation as found out by apt search
. After installing openjdk-8-jre the simlinks were replaced and the directory structure otherwise stayed the same.
What worked for me is:
java
path is available:$ which java
/usr/bin/java
netbeans_jdkhome
is commented outYou would expect ./netbeans --jdkhome=/usr/bin/java
to work, but it doesn't for some reason.
Try Java SE Runtime Environment 8. It fixed it for me.
NetBeans 8.2 - Cannot locate java installation in specified jdkhome?
Answer: Edit the netbeans.conf file.
Close NetBeans, start Notepad or another text editor as Administrator. Right click on the Notepad application and choose "Run as administrator" and then open netbeans.conf with it. Change netbeans_jdkhome=”C:\Program Files...whatever”.
With the Netbeans 10, commenting out the netbeans_jdkhome
setting in .../etc/netbeans.conf
doesn't do the job anymore. It is necessary to specify the right directory depending of 32/64 bitness.
E.g. for 64 bit application: netbeans_jdkhome="C:\Program Files\AdoptOpenJDK\jdk8u202-b08"
example:
sudo vim /usr/local/netbeans-8.2/etc/netbeans.conf
First, please remember that in a Mac computer the netbeans.conf file is stored at
/Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf
(if you had used the default installation package.)
Then, also remember that the directory you MUST use on either "netbeans_jdkhome" or "--jdkhome" it's NOT the /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/ but the following one:
/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home //<-- Please, notice the /Contents/Home at the end. That's the "trick"!
Note: of course, you must change the versions for both NetBeans and JDK you're using.
If like me, you got that message after installing jenv,
simply add netbeans_jdkhome="$JAVA_HOME"
to your [netbeans-installation-directory]/etc/netbeans.conf
file
Check the setting in your user config /home/username/.netbeans/version/etc/netbeans.conf
I had the problem where I was specifying the location globally, but my user setting was overriding the global setting.
CentOS 7/Netbeans 8.1
Source: Stackoverflow.com