Omit the .class
java HelloWorld
Frage
In eclipse, I suddenly get the following error:
<terminated> Adding more memory. [Java Application] /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
With the stacktrace:
Exception in thread "main" java.lang.NoClassDefFoundError:
Caused by: java.lang.ClassNotFoundException:
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
I've tried googling it, and I have no idea why this is occurring... I've tried closing and reopening eclipse, and rebooting. I was happily coding an Android project (which was compiling a few minutes ago) when this started happening.
FYI, the code I am trying to compile is:
public class HelloWorld {
public static void main(String[] args){
System.out.println("Hello World");
}
}
It works, however in the terminal (after silly late night correction)
Jono@Lappy:/Users/Jono/Workspace/HelloWorld/src$ ls
HelloWorld.java
Jono@Lappy:/Users/Jono/Workspace/HelloWorld/src$ javac HelloWorld.java
Jono@Lappy:/Users/Jono/Workspace/HelloWorld/src$ ls
HelloWorld.class HelloWorld.java
Jono@Lappy:/Users/Jono/Workspace/HelloWorld/src$ java HelloWorld
Hello World
I am running a Macbook Pro with OSX 10.7.5, completely up to date.
Keine korrekte Lösung
Andere Tipps
Omit the .class
java HelloWorld