+ 2

How to fix "Could not find or load main class. " problem in Eclipse Java 2012.

Hi. I installed Oracle JDK already before I installed Eclipse Indigo 2012 for Java. But it doesn't run my first Hello World program. I googled and I found it as path problem. But I can't find how to fix it yet. I use Window 7. Thanks in advance.

20th Mar 2019, 1:38 PM
Khaing Khaing Mon
Khaing Khaing Mon - avatar
9 Respuestas
+ 3
Few important things. Your filename should be exactly the same, with the same capitalization, as the class in your program which contains the main method. Eg: HelloWorld.java public class HelloWorld { Then I suggest to check if you can compile your program from command line. Open shell, switch to the directory where your java source file is, and try: javac HelloWorld.java If it does not work, it might be a path problem. If it works then I think it can be an issue with Eclipse setup.
21st Mar 2019, 6:29 AM
Tibor Santa
Tibor Santa - avatar
21st Mar 2019, 6:32 AM
Tibor Santa
Tibor Santa - avatar
+ 3
Are you able to compile and run the program from the command line? (without using Eclipse) Do you get the same error? You can check the Classpath setup in Eclipse too, maybe it helps https://www.techwalla.com/articles/how-to-set-the-classpath-in-eclipse
21st Mar 2019, 7:05 AM
Tibor Santa
Tibor Santa - avatar
+ 3
I am pretty sure it is an Eclipse setup issue, then. I use a different IDE so can't test. If this does not help, try googling 'eclipse classpath' to find more resources... http://javahowto.blogspot.com/2006/06/set-classpath-in-eclipse-and-netbeans.html?m=1
21st Mar 2019, 7:21 AM
Tibor Santa
Tibor Santa - avatar
+ 2
I could do it well in command line. error just happened in eclipse.
21st Mar 2019, 7:07 AM
Khaing Khaing Mon
Khaing Khaing Mon - avatar
+ 1
Yes, it is a path problem. How can I fix it?
21st Mar 2019, 6:30 AM
Khaing Khaing Mon
Khaing Khaing Mon - avatar
+ 1
Thanks. But I already did that too. Still it can't find yet.
21st Mar 2019, 6:36 AM
Khaing Khaing Mon
Khaing Khaing Mon - avatar
+ 1
Tibor Santa: I can't see the pics in the link clearly
21st Mar 2019, 7:13 AM
Khaing Khaing Mon
Khaing Khaing Mon - avatar
+ 1
Thanks, Tibor Santa
21st Mar 2019, 7:23 AM
Khaing Khaing Mon
Khaing Khaing Mon - avatar