My Eclipse (Indigo) was running just fine. I created a simple class Hello
. It is placed in package cont
in the folder ch13
. However
I solved my issue by doing this:
Strangely it started working again after that.
It is possible to have 2 groovy-xxx-all.jar files by excample in lib directory. which makes that an app is not running
Another tip: I initialized static fields in a wrong order - surprisingly it didn't bring up a Problem (NullPointerException?), instead Eclipse complained with exactly the message OP posted. Correcting the static initialization order made the class run-able. Example:
private static ScriptEngineManager factory = null;
private static ScriptEngine engine = null;
static {
engine = factory.getEngineByName("JavaScript");
// factory is supposed to initialize FIRST
factory = new ScriptEngineManager();
}
Note: This worked in the past and I received many up votes. Perhaps this is not a solution anymore - but it once was - as the eclipse version was indicated.
This can also be caused by a Java Build Path Problem.
In my case, I had a an error:
A cycle was detected in the build path of project {project}. The cycle consists of projects {x, y, z}.
This can occur when you include other projects in the build path of the project you wish to run. In fact, all the projects will fail to run with the error
Could not find the main class: Example.class
Windows
-> Preferences
-> Java
-> Compiler
-> Building
-> Build Path Problems
Abort build when build path errors occur
toggleThis seems like a can of worms if you end up with other build path errors I image. So use with caution.
I found the solution to this here
Info
I had this issue after upgrading to the Eclipse 2019-12 release. Somehow the command line to launch the JVM got too long and I had to enable the jar-classpath option in the run configuration (right click on file -> run as -> run configs).
I had this same problem in a Maven project. After creating the src/test/java folder within the project the error went away.