I am currently using Ubuntu 11.10 and java SE 1.6.0_26. I am trying to run a very simple "Hello World" app. I placed the the java file HelloWorld.java
on the Home folder. I compiled it using the command javac HelloWorld.java
. I think its working because it doesn't show any compilation error and a HelloWorld.class
is created.
When I typed the command java HelloWorld
I have this error:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
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)
Could not find the main class: HelloWorld. Program will exit.
BTW, here is my java code:
public class HelloWorld {
public static void main (String args[]) {
System.out.println("Hello World!!!");
}
}