this seams to be a comman problem but all the solution on the web didnt help. I am using the default java given by suse10.3
i am pasting my files file.java at
/srv/java
i am executing/compiling as
javac file.java //comipling
java file // exeuting it
i get no error on comipling but on executing it Exception in thread “main” java.lang.NoClassDefFoundError
MY
JAVA_HOME=/usr/lib/jvm/java
JAVA_ROOT=/usr/lib/jvm/java
JDK_HOME=/usr/lib/jvm/java
this is ALL that i have tried
javac -classpath . file.java
java -classpath . file
and
javac -cp . file.java
java -cp . file
and
javac -cp /srv/java file.java
javac -cp /srv/java file.java
and
i moved file from /srv/java to JAVA_HOME
i also set the CLASSPATH variable using
export CLASSPATH=/srv/java
Is this class in the same directory as the rest of your classes - or is it in a lib somewhere else?
i didint get you
see i have created a folder called java inside src and here i am pasting my files this is not default location created by java but by me…
Can you try compiling and running a simple helloworld program?
Something like:
class helloworld {
public static void main(String] args) {
String howdy = "Hello world!";
System.out.println(howdy);
}
}
saved somewhere in your home directory as “helloworld.java”. Then open a terminal and cd to it, and compile using:
javac . helloworld.java
and run using:
java helloworld
If this works, move your other files into the same dir and try compiling them again.
HTH
ram88
December 16, 2008, 12:20am
#5
Open your file.java source file. And paste here the lines with
package …
import …
Do not set the CLASSPATH variables, add to the compiling options with
javac -classpath dir1/class dir2/anotherClass
.
Maybe you need to define the root patch, do this with the compiler option:
javac -d . file.java
. - if your are in the directory where the file.java is located.
Good luck.