Class Not Found

Hi all. Ok. I have been have been having this problem:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NoClassDefFoundError: BasicEnvironment/StaticTerrain
at Main.Main.setupTerrain(
at Main.Main.simpleInitApp(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(
Caused by: java.lang.ClassNotFoundException: BasicEnvironment.StaticTerrain
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
… 6 more

I am not sure how this is possible because I have BasicEnvironment/StaticTerrain :-? . This is the third time this has happened. This error is like random sometimes it says some other class does not exist but it does exist. To fix this I make a new package and put the classes in there and then it works again but this is rather getting annoying -.- . Is there a solution for this?

This is the code for the Main class:

package Main;

import BasicCharacter.EnemyGenerator;
import BasicCharacter.Player;
import BasicEnvironment.Building;
import BasicEnvironment.StaticTerrain;
import BasicEnvironment.TowerGenerator;
import com.jme3.bullet.BulletAppState;
import com.jme3.font.BitmapText;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import de.lessvoid.nifty.Nifty;

public class Main extends SimpleApplication {

Player player;
StaticTerrain dummyGround;
TowerGenerator towerGenerator;
EnemyGenerator enemyGenerator;
Building mainBuilding;

BulletAppState bulletAppState;

public static Nifty nifty;

public static void main(String[] args) {
    Main app = new Main();

public void simpleInitApp() {

// setDisplayFps(false);
viewPort.setBackgroundColor(new ColorRGBA(0.7f,0.8f,1f,1f));


// setupAimTest();

private void setupAimTest() {
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
    ch.setText("+"); // crosshairs
    ch.setLocalTranslation( // center
      settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2,
      settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);

public void loadHUD(){
    NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, 
    nifty = niftyDisplay.getNifty();
    nifty.fromXml("Interface/HUD.xml", "start");

private void setupBuilding(){
    mainBuilding = new Building(assetManager, new Vector3f(-40, 0, 40), "Main", player);

private void setupTowerGenerator(){
    towerGenerator = new TowerGenerator(assetManager, enemyGenerator.enemy, nifty);
    //Enemy Generator setup
    enemyGenerator.setupTowerAndPlayer(towerGenerator.tower, player);

private void setupCollision(){
    bulletAppState = new BulletAppState();

// bulletAppState.getPhysicsSpace().enableDebug(assetManager); //<-----for debugging only

    //====Adding Enemy Bullet.CharacterControl
    for(int i = 0; i &lt; enemyGenerator.enemy.length; i++){
        for(int j = 0; j &lt; enemyGenerator.enemy[i].bulletGenerator.bullet.length; j++){
    //====Adding Player Bullet.CharacterControl
    for(int i = 0; i &lt; player.yellowBullet.bullet.length; i++){
    for(int i = 0; i &lt; player.blueBullet.bullet.length; i++){

private void setupEnemy(){
    enemyGenerator = new EnemyGenerator(assetManager, mainBuilding, nifty);
    for(int i = 0; i &lt; enemyGenerator.enemy.length; i++){
    //=======Send EnemyList to Player======//

private void setupPlayer(){
    player = new Player(assetManager, inputManager, new Vector3f(0, 2, 0), &quot;Player&quot;, nifty);

private void setupTerrain(){
    dummyGround = new StaticTerrain(assetManager, Vector3f.ZERO, &quot;DummyGround&quot;);

private void setupLight(){
    AmbientLight ambient = new AmbientLight();
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());

private void setupBloom(){
    FilterPostProcessor fpp=new FilterPostProcessor(assetManager);
    BloomFilter bf=new BloomFilter(BloomFilter.GlowMode.Objects);

public void simpleUpdate(float tpf){
            cam.getLeft().clone().multLocal(0.2f), cam.getRotation(), tpf));

private void UpdateBuilding(){

private void UpdateEnemy(float tpf){

private void UpdatesTower(float tpf){
        player.tower = false;
        towerGenerator.addTower(player.physics.getPhysicsLocation(), cam.getDirection().clone());
        for(int i = 0; i &lt; towerGenerator.getTower().getBulletGenerator().bullet.length; i++){


Did you clean&build some time?

Yes I did, but still does not work. This time it can not find any of the classes. So what i did was make a new project and copy paste src and asset folder to the new project and it works. But the issue still remains of that exception coming back after sometime. :expressionless:

Windows I gather? Did you try restarting the SDK? Do you use the jar libraries of that project outside of the project? Like if some other app opens these, windows will lock them and the SDK cannot read them.

Yes its windows. Yes I restarted the SDK. No I don’t use jar libraries outside of the project.


Do you put your classes in a folder or a package?


Maybe its got something to do with the case of the package? As per the java spec only lower case names are allowed for packages.

In the package naming I give the first letter capital and the rest lower case. I don’t think package naming is the problem because it is working at first and after sometime it gives the problem. So, if package naming was the issue then the problem would have been given at the beginning rather than later.

Not really, if the OS registers different filenames based on case and at some point some script assumes your package names are lower case and converts some config file then not :slight_smile: Also I don’t know how the different classloaders handle this. But anyway I just wanted to give you something to try, not exchange hypotheses on processes.

I have been working with the game till now and didn’t get the problem yet. But when I do I will try your method and make the package name to lower case. It’s kool to try something new though :slight_smile: . Thanks Normen XD .

Lower case package names are a convention and not a language requirement. Even the guidelines tend to say “use lower case whenever possible”.

kool, didn’t notice the guidelines, will follow that then from now on. Good news is that I still haven’t got that problem yet but once I do I will make the changes.

Thanks all.

K Out!

I wanted to mention I just ran into this issue

[java]Exception in thread “main” java.lang.NoClassDefFoundError: mygame/planHead
at mygame.Main.<init>(
at mygame.Main.main(
Caused by: java.lang.ClassNotFoundException: mygame.planHead
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
… 2 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)[/java]

I just restarted my IDE and this came up…? Really annoying and upsetting. I wouldn’t have to restart if I wouldn’t keep getting “out of memory issues” I increased the heap size too…

I don’t know if it exactly happened after I restarted, because I went and reverted from my history after the edit, so Idk if that had anything to do with it?

My package name is “mygame,” which is the default I believe, as well as only using these files for this application/jar, etc.

I have tried resetting the ide multiple times, as well as clean and clean/build. I read up that it could be due to a pathing issue, but it seems to be okay, so I’m not sure what’s going on… really upsetting…

If your class name is really “planHead” with a lower case P then it’s named incorrectly. Maybe you have a typo somewhere? Or did you really name the class with a funny capitalization?

@pspeed said: If your class name is really "planHead" with a lower case P then it's named incorrectly. Maybe you have a typo somewhere? Or did you really name the class with a funny capitalization?

Yeah, I accidentally named it that way… I didn’t think that would mess it up… I had one called SimpleApp that also messed it up as well as “Vector3F,” is this named wrong? I did’t want “Vector3f” or something similar so after trying a few different times and a whole bunch of random errors occurred, then undid everything and it all works…

Achievement unlocked, we don’t ask questions LOL :).

Thank you as always!!!

EDIT: Another class “FlyCam” just did it as well, it seems to keep breaking every time i try to debug my code…"

It seems to “run” after I refactor, but now when I try to debug again
Njow I got a [java]
Apr 20, 2014 10:35:08 PM handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NoSuchFieldError: flyCam[/java]

it seems to work after running it again… WEIRD…

There is something very wrong with your setup but I have no idea what it could be.

I’ve been developing this code for a long time, I don’t know what could have spurred this change, I didn’t do anything odd surrounding the issue, but all seems well now. I understanding the naming issue "not too sure why some of them went off when they were named correctly and Idk why it lasted so long as “planHead?”

Hve you tried, backing zup the pure src, killing all and reinstall the skd,
past code back into? That way you could rule out problems with the sdk installations. As this sounds kinde strange.

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.

Exception in thread “main” java.lang.NoClassDefFoundError: mygame/states/GameState
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(
at java.lang.Class.getMethod0(
at java.lang.Class.getMethod(
at sun.launcher.LauncherHelper.getMainMethod(
at sun.launcher.LauncherHelper.checkAndLoadMain(
Caused by: java.lang.ClassNotFoundException: mygame.states.GameState
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
… 6 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)