Netbeans 7.0 and "Cannot find java. Please use the -- jdkhome switch"

Netbeans LogoWhy do I like coding in Netbeans IDE? I don't really know why, I just do. Don't get me wrong, I use Eclipse and it is a great tool but Netbeans and me go way back. But unfortunately there is a little hiccup with the latest Netbeans 7.0. Installing Netbeans while having OpenJDK results in Netbeans refusing to start with error message "Cannot find java. Please use the --jdkhome switch" when you try to start it with Sun (now Oracle) Java. The fix for this annoying bug (I guess we can call it bug) is rather trivial so read on.

"netbeans.conf" is the patient we will operate on. You can find this file inside "/usr/local/netbeans-7.0/etc/" directory (depending on where you have installed Netbeans). So lets open it like this:

gksudo gedit /usr/local/netbeans-7.0/etc/netbeans.conf

Now find the "netbeans_jdkhome" option and make it look like this:

# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="/usr/lib/jvm/java-6-sun"

All that's left is to have fun coding using Netbeans with your favorite programming language.

DevGenii

A quality focused Magento specialized web development agency. Get in touch!

11 thoughts on “Netbeans 7.0 and "Cannot find java. Please use the -- jdkhome switch"

  1. karim

    This problem troubled me for a little while : i’m working under kubuntu 12.04, i first installed netbeans for C/C++, and then installed python modules to work with python files, and what heppend ?? after python plugins being installed, the whole platform crashed and kept showing me that error (bla bla bla need java 7 or use –jdkhome swithc bla bla bla ..) i thought the problem would be solved simply by installing java 7 but that never happend, I googled it and come across this,
    however this didn’t solved the issue in my case it helped me solving the problem : once i changed the netbeans.conf file, netbeans works only when started from /usr/local/netbeans-7.3.1/bin and kept showing the error message when started from the Kstart menu, so I edited $HOME/netbeans-7.3.1/etc/netbeans.conf” and changed specified line to : netbeans_jdkhome=”/usr/lib/jvm/java-1.7.0-openjdk-i386″ whooh, it works I shouted 😀
    I’m posting this hoping it will help someone having the some issue
    #ubuntu #kde # netbeans #java7 #–jdkhome switch

    Reply

Leave a Reply to karim Cancel reply

Your email address will not be published. Required fields are marked *