Class Not Found

@kruze said: Hi all!

I just run into the same problem.

I’ve been working on a game since september and I use this class everytime I start up my game. About 30 minutes ago, my SDK failed to run my game due to lack of memory. So I restarted my pc to have a clean start, and when I hit run, the error above welcomes me. I was not able to run my game since pc restart because it tells me that my GameState class is missing, but I can confirm that it’s there, it has always been there (and will be) with the same package name.

Clean and rebuil doesn’t help.

[java]
Exception in thread “main” java.lang.NoClassDefFoundError: mygame/states/GameState
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: mygame.states.GameState
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
… 6 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
[/java]

Try doing what I did, refactor the class name and see if it runs, then refactor back, that worked for me a few times.

Hope this helps.

As for this heap poo. The heap should be bigger automatically, and there should be an easier way to fix the size, especially for noobies to what exactly we need. I tried changing the values according to the tutorial, but it got reset back to it’s old values, so Idk what’s up with that.

All right, I found out the magic how to fix this:

In File Menu, select Project Properties(yourproject). Under Categories, select Sources (it selects it automatically because its the first entry), then under Source Package Folder, select src Package Folder and remove it. Then click Ok, run your game, let it fail. Then go back to Project Properties and under Source Package Folders click Add Folder and select your src folder. Click Run and it will work.

I don’t know why this made my game run again… :lol: :-?

Looks like @KonradZuse, we just found two solutions. :stuck_out_tongue_winking_eye:

About the memory stuff: I was into some research and fast prototyping and I just modified my code and restarted my game a lots of times. I didn’t care about clean code or about memory usage because I wanted an answer to a question… And then suddenly, almost all of my system memory got wasted… so it’s my bad. I will fix things if I find my answers. Thanks by the way! :slight_smile: