Java is not working with netbeans IDE 7 on ubuntu 11.10

Vipin Kr. Singh picture Vipin Kr. Singh · Apr 19, 2012 · Viewed 10.3k times · Source

I am using Netbeans IDE 7.1.1 on ubuntu 11.10, when I try to create JAVA project using File-> New Project-> JAVA Project-> JAVA Application, it shows me the following error:

The JDK is missing an required to run some NetBeans modules. Please use the --jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJre for more information.

So I used the following command

sudo update-alternatives --config java

and the result was:

    Selection    Path                                           Priority   Status
------------------------------------------------------------
    0            /usr/lib/jvm/java-6-openjdk/jre/bin/java        1061      auto mode
    1            /usr/lib/jvm/java-6-openjdk/jre/bin/java        1061      manual mode
  * 2            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1051      manual mode

I tried to run through terminal using the following command:

netbeans --jdkhome /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java

but I got error:

Cannot find java. Please use the --jdkhome switch.

and netbeans doesn't start as well.

I tried this command using every path which I found through this command also:

whereis java

but every time I got the same error and netbeans doesn't start.

in netbeans config file (/usr/local/netbeans-7.0/etc/netbeans.conf) jdkhome path is :

netbeans_jdkhome="/usr/lib/jvm/java-7-openjdk-i386/jre"

when I tried to run netbeans using this path through this command:

netbeans --jdkhome /usr/lib/jvm/java-7-openjdk-i386/jre

netbeans runs but when try to create project the same JDK missing error is displayed.

One interesting thing also I encountered, if I use Eclipse every thing goes fine, I am able to create projects in eclipse and programs run smoothly. Eclipse doesn't show any wanning or errors like JDK is missing.

Answer

Max picture Max · Apr 19, 2012

I use Netbeans 7.1 on Ubuntu 11.10 and it works great, I didn't need to specify anything extra to get the JDK working. Here is my update-alternatives:

Selection    Path                                      Priority   Status
 ------------------------------------------------------------
  0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
* 1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode

How did you install Netbeans 7.1? As far as I remember it is not in the repositories. I used the GUI Swing installer from the Netbeans website. I installed it as a user not using sudo or su.

Also check how you run Netbeans, try going to NETBEANS/bin folder and running ./netbeans.