Lỗi could not find or load main class

Have Googled extensively on this error, but I can"t seem to fix the problem. I"ve written a basic java program in Eclipse Juno, as follows:

public class HelloWorld /** *
param args */ public static void main(String<> args) System.out.println("Hello Eclipse!"); After clicking Run, I get: "Error: Could not find or load main class HelloWorld". This error message applies to all my other projects in the same workspace. I"ve tried switching workspaces but the error still appears.

Bạn đang xem: Lỗi could not find or load main class

I"m on Windows 7 64-bit. Any help would be appreciated!


This just happened to me today after updating my JRE. I cleaned the project and it started working again.

Project -> Clean will remove any existing class files and completely rebuild the project. There"s more information on Eclipse"s clean function here.



I just ran into that problem. The cause... not sure. However, only happened after I added a new jvm.My solution:

went to run configurations: - run->run configurations

In the Classpath tab:

Select Advanced Add where Eclipse usually put the *.class for the projects, which is in bin. So I added the bin directory for the project.

I hope it helps someone out there. It took me time to figure this out.


I deleted a jar file from the bin directory. Right click on your project - Properties then Libraries tab. There was a red flag in there. I removed the jar file from the Libraries and it worked.


It seems that the class is not compiled by Eclipse.

Xem thêm: Top Hình Nền Powerpoint Công Nghệ Khoa Học Cực Chất, 50 Phông Nền Powerpoint Khoa Học Đẹp Nhất

Few pointers could be-

Check if the .class file exists in your output folder.To know your output folder Right Click on Project->Properties->Java Build Path(Check at bottom).Check if Project->build Automatically is checked in the menu.Check if the HelloWorld class is in src folder or not.Right Click on Project->Properties->Java Build Path(Check source tab).
Same Problem occur with me.I went to Project > Properties > Java BuildPath.

There In order of export , I moved up my java/main to the top priority.

that"s because you guys created the class one time with the main method & after that may be you have been deleted that form or workplace & still some of the files exist ,i will suggest you to create that form or workspace again & then delete it by clicking on it completely,then after that if you created the some class like Runner class try to run it again.

This happened to me. I noticed that someone said I have to create an entire new WORKSHOP! Why? Because I installed a newer JRE version and that won"t allow other previous versions to run on it. So all those old files I have become useless in a way. Not really, Just copy and paste it to new class and change it to an unused class name.

Not the answer you're looking for? Browse other questions tagged java eclipse or ask your own question.

Eclipse - Error: Main method not found in class projectOne, please define the main method as: public static void main(String<> args)
site design / logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2022.3.24.41762

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.