I'm trying to run one of the first examples from the book "Head First Java",
public class MyFirstApp { public static void main (String[] args){ System.out.println("I Rule!"); System.out.println("The Worlds!"); } }
"javac" created the .class file from the .java file, but "java" complains about the "missing main class" when trying to run the .class file (I also tried java -cp. "..." with the same result):
C:\>java \hfj\MyFirstApp.class Exception in thread "main" java.lang.NoClassDefFoundError: \hfj\MyFirstApp/class Caused by: java.lang.ClassNotFoundException: \hfj\MyFirstApp.class 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: \hfj\MyFirstApp.class. Program will exit.
source share