1

When I set name and location of a new Java project it stops and show a message of error :

A java.lang.NoClassDefFoundError exception has occurred

So the project isn't created and I can write any code lines on Netbeans.

My OS version

  • Ubuntu 14.04.2 LTS 64 bit

My NetBeans version

  • Product Version: NetBeans IDE 7.0.1 (Build 20121011-unknown-revn)
  • Java: 1.7.0_75; OpenJDK 64-Bit Server VM 24.75-b04
  • System: Linux version 3.13.0-49-generic running on amd64; UTF-8; it_IT (nb)
  • Userdir: /home/ema/.netbeans/7.0
8
  • Post the exception.
    – A.B.
    Apr 11, 2015 at 11:05
  • 1
    @A.B. He has already posted the exception A java.lang.NoClassDefFoundError exception has occurred Apr 11, 2015 at 11:28
  • Have you set classpath in ~/.bashrc and /etc/profile . The error shows that it cannot find class definitions. And the predefined class definitions are located in classpath Apr 11, 2015 at 11:32
  • @Faizan, that is only a part of the complete ecxeption.
    – A.B.
    Apr 11, 2015 at 11:34
  • Check this for setting up classpath in ubuntu. Apr 11, 2015 at 11:41

1 Answer 1

0

You need to set up CLASSPATH in /etc/environment. Execute the following command in a terminal (Ctrl+Alt+T)

 sudo gedit /etc/environment

Add the following lines (all four lines at the end of /etc/environment)

JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/bin"
export JAVA_HOME
CLASSPATH="/usr/lib/jvm/java-7-openjdk-amd64/lib"
export CLASSPATH

Then restart your system.

8
  • In the terminal after i run the first line( sudo gedit /etc/environment ) and add this JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/bin" I see this message: (gedit:3222): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files Apr 13, 2015 at 18:46
  • No problem, just save the file and restart system. It should work now. Ignore these messages Apr 13, 2015 at 18:48
  • nothing changes and when I run the export command in the terminal nothing happens Apr 13, 2015 at 19:03
  • @EmaJ You dont have to run export command in terminal rather you have to add all these four lines to /etc/environment also add these lines to ~/.bashrc . Execute gedit ~/.bashrc in terminal and add these four lines to it and save it. Apr 13, 2015 at 19:10
  • I've run the commands and added the lines but can created any project on netbeans. Apr 13, 2015 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .