I made this tiny code:
public class main
{
public static void main(String[] argv)
{
System.out.println("Hey");
}
}
It compiles and run fine in eclipse, but when i go into cmd and do
javac main.java it created a main.class
then I did
java main.class
but I get errors..
C:\ecjava\herp\src>java main.class
Exception in thread "main" java.lang.NoClassDefFoundError: main/class
Caused by: java.lang.ClassNotFoundException: main.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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: main.class. Program will exit.
How can I fix it?
I also want to make an executable JAR, making it easy to just send it to a friend who can run it.
But I believe it produced the same error as above.