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 also had the same issue and was getting "Error: Could not find or load main class ...."
I solved it as follows:
Right clicked on my Java main class > Run As > Run Configurations.
In the resultant popup box and Under Java Application your java file name would be selected mode... if not select it
Under Bootstrap Entries Click Advanced Button > Select Add Library Radio and click OK. In next "Add Library" box Select JRE System Library and provide your correct JRE location and click Finish. (If it is not visible then u have to add it by clicking Installed JRE > Add button). Now you can see JRE System Library under BootStrap Entries
Next User Entries > Click Add Projects Button > And then under Project Selection box check on your Project name > OK
The main java file should now work. Hope this may help someone who would be facing similar issues.