"Could not find the main class"
Hello,
I am very new to java and recently attempted to run my first program. I created a simple program I found online in notepad
Code:
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
I saved this as "HelloWorldApp.java" and then went to my command prompt, went to the correct location, complied it using "javac HelloWorldApp.java", made sure the "HelloWorldApp.class" file was present, and then attempted to run the program by typing "java HelloWorldApp". This gave me an error saying
Quote:
C:\Documents and Settings\Chris\My Documents\School>java HelloWorldApp
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp
Caused by: java.lang.ClassNotFoundException: HelloWorldApp
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: HelloWorldApp. Program will exit.
I don't know what to do to fix this issue. I have found similar issues being fixed by changing the Environmental Variables, but I already changed the PATH and CLASSPATH to "C:\Program Files\Java\jdk1.6.0_21\bin".
Any help would be greatly appreciated!