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 came across the same problem. You might get this error in many situations like below.
mvn clean, mvn build and other options.Here, the list of hit and trial goes on. Believe me the tool Eclipse is not that stupid. It is quite smart to find errors even at compile time. I tried all ways mentioned above, but none worked for me.
The main problem which worked for me was JRE version which was somehow got set to default (JRE System Library [jre1.5]). I reset it to jre1.8.* which I had installed in my machine.
I don't commit that this is only the solution to this problem but yes this could be one of the solution. So keep an eye on JRE version.