I know there are many duplicates of this question, but I have looked at them all, and none of them have solved the issue.
I am trying to run a class that has a main
i had same problem but in my case firewall was blocking java directory path, make sure system firewall is allowing java directory path access.
I had similar problem, my standalone java program was not working. I had other compilation error in my workspace in other unrelated java files. After removing all compilation errors I could run my standalone java program.
If all the solution does not work for you, it may be caused by missing libraries:
Build Path --> Configure Build Path --> Java Build Path --> Libraries
I have checked all possible solutions including re-installation of JDK, eclipse as it worked for many people but unfortunately it didn't work for me. Also updated main class in pom.xml but it didn't help. It took my sleep away. I was trying different options and suddenly the magic happened when I checked this checkbox. It might be helpful for many people so thought of sharing
If you are facing similar problem,it has to do with the "Run Configurations" not working properly in Eclipse.
Please right clik on your java class containing the main method .Go to Run As-> Run Configurations and put the correct patrameters.Project should be the Project which contains the main class and Main class should be fuly qualified class name.See the snapshots below for clarity.It should wok fine then.Basically,you are creating a Run configuration and you can use that saved configuration for later use also.
Try to check first in the Problems window the errors you have. It is most likely it. Then check in the Configure Build Path... window under Order and Export for errors in jars and libraries (missing, duplicates, etc.).
Fixing the problems will fix the class-loading issue.