Issue
My program was running fine on eclipse as well as through command line. But now it not running on eclipse, but it is still running through the command line. Now error on the eclipse console is:-
java.lang.NoClassDefFoundError: Hi
Caused by: java.lang.ClassNotFoundException: Hi
at java.net.URLClassLoader$1.run(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
I am running my progam on Eclipse EE. But, there is nothing other that Hi.java file. Location of Hi.java is-
test
|src
|test
|Hi.java
There is no other file than Hi.java is present. I want to just find, why this error is coming up.
When i am running the program through command line then it is correctly producing output:-
C:\Users\Rahul kumar\desktop>javac Hi.java
C:\Users\Rahul kumar\desktop>java Hi
Hi
There is no error in my program. My program:-
public class Hi {
public static void main(String[] args) {
System.out.println("Hi");
}
}
The main this is that programs are running correctly on eclipse a day ago. I have not changed classpath or environment variables.
I went through some website and some asked question on StackOverflow. Some of them are not related to my issue. But, they didn't solve my problem. I went through the following websites and asked questions.
Javarevisited
javarevisited
stackoverflow question
Solution
As you are running this on eclipse EE, One thing might happen that, this is runing in server. Always choose run as java application.
Answered By - user13319825