There’s a major bug were very often I get a:
java.lang.NoClassDefFoundError: mygame/Enemy
Caused by: java.lang.ClassNotFoundException: mygame.Enemy
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: mygame.Main. Program will exit.
Exception in thread “main” Java Result: 1
It is such a hassle because it takes a lot of time to get it to stop. Sometimes I need to rebuild the project, sometimes all I have to do is comment out a random section of code, run it, then un comment it and it works. A while ago, I could switch the project from JVM 1.6 to 1.7 back to 1.6 and that worked but times like now, nothing works. This is very frustrating and i am curious if any of you have figured out a reliable solution to get around this issue.
@normen said:
Try "clean and build" when you change the JDK. Alternatively try disabling "Build on save" in the project settings.
I tried all of that and I ended up deleting the all my other JDK's to see if that would eliminate the error. I commented out the entire class, compiiled, un commented, and ran the game and it seems to work now. Very strange error.
@Jmonkier said:
There's a major bug were very often I get a:
java.lang.NoClassDefFoundError: mygame/Enemy
Caused by: java.lang.ClassNotFoundException: mygame.Enemy
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: mygame.Main. Program will exit.
Exception in thread "main" Java Result: 1
It is such a hassle because it takes a lot of time to get it to stop. Sometimes I need to rebuild the project, sometimes all I have to do is comment out a random section of code, run it, then un comment it and it works. A while ago, I could switch the project from JVM 1.6 to 1.7 back to 1.6 and that worked but times like now, nothing works. This is very frustrating and i am curious if any of you have figured out a reliable solution to get around this issue.
Actually, just altering the file in question in anyways and then saving it will fix this (adding and removing a blank line, then saving). You don’t need to comment, run, then uncommen, run againt. This will save u an extra step until you resolve the issue. It’s still irritating when it happens… especially when it’s a significant number of files that became corrupted.
I haven’t had this happen in a long time knock on wood