I am trying to run a java program from command line. I tried following the steps mentioned here. But when I try to run javac Hello.java
, it's throwing error that such a program is not there. I tried giving java Hello.java
and got the error:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello/java
Caused by: java.lang.ClassNotFoundException: Hello.java
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: Hello.java. Program will exit.
What is the problem here. How can I do it?
EDIT: I have many classes in my code file, Hello.java. Will that cause any problem?