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(Main.java:139)
at Main.Main.simpleInitApp(Main.java:50)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: BasicEnvironment.StaticTerrain
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
… 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:
[java]
package Main;
import BasicCharacter.EnemyGenerator;
import BasicCharacter.Player;
import BasicEnvironment.Building;
import BasicEnvironment.StaticTerrain;
import BasicEnvironment.TowerGenerator;
import com.jme3.app.SimpleApplication;
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.post.FilterPostProcessor;
import com.jme3.post.filters.BloomFilter;
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();
app.start();
}
@Override
public void simpleInitApp() {
// setDisplayFps(false);
setDisplayStatView(false);
viewPort.setBackgroundColor(new ColorRGBA(0.7f,0.8f,1f,1f));
flyCam.setMoveSpeed(30f);
setupLight();
setupBloom();
setupTerrain();
loadHUD();
setupPlayer();
setupBuilding();
setupEnemy();
setupTowerGenerator();
setupCollision();
// setupAimTest();
}
private void setupAimTest() {
guiNode.detachAllChildren();
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);
guiNode.attachChild(ch);
}
public void loadHUD(){
flyCam.setDragToRotate(false);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
inputManager,
audioRenderer,
guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml("Interface/HUD.xml", "start");
guiViewPort.addProcessor(niftyDisplay);
}
private void setupBuilding(){
mainBuilding = new Building(assetManager, new Vector3f(-40, 0, 40), "Main", player);
rootNode.attachChild(mainBuilding.rootNode);
}
private void setupTowerGenerator(){
towerGenerator = new TowerGenerator(assetManager, enemyGenerator.enemy, nifty);
//Enemy Generator setup
enemyGenerator.setupTowerAndPlayer(towerGenerator.tower, player);
}
private void setupCollision(){
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
// bulletAppState.getPhysicsSpace().enableDebug(assetManager); //<-----for debugging only
bulletAppState.getPhysicsSpace().add(player.physics);
bulletAppState.getPhysicsSpace().add(dummyGround.getPhysics());
bulletAppState.getPhysicsSpace().add(mainBuilding.rigidBody);
bulletAppState.getPhysicsSpace().add(mainBuilding.door1.rigidBody);
//====Adding Enemy Bullet.CharacterControl
for(int i = 0; i < enemyGenerator.enemy.length; i++){
bulletAppState.getPhysicsSpace().add(enemyGenerator.enemy[i].physics);
for(int j = 0; j < enemyGenerator.enemy[i].bulletGenerator.bullet.length; j++){
bulletAppState.getPhysicsSpace().add(enemyGenerator.enemy[i].bulletGenerator.bullet[j].getPhysics());
}
}
//====Adding Player Bullet.CharacterControl
for(int i = 0; i < player.yellowBullet.bullet.length; i++){
bulletAppState.getPhysicsSpace().add(player.yellowBullet.bullet[i].getPhysics());
}
for(int i = 0; i < player.blueBullet.bullet.length; i++){
bulletAppState.getPhysicsSpace().add(player.blueBullet.bullet[i].getPhysics());
}
}
private void setupEnemy(){
enemyGenerator = new EnemyGenerator(assetManager, mainBuilding, nifty);
for(int i = 0; i < enemyGenerator.enemy.length; i++){
rootNode.attachChild(enemyGenerator.enemy[i].rootNode);
}
//=======Send EnemyList to Player======//
player.setupEnemyList(enemyGenerator.enemy);
}
private void setupPlayer(){
player = new Player(assetManager, inputManager, new Vector3f(0, 2, 0), "Player", nifty);
rootNode.attachChild(player.rootNode);
}
private void setupTerrain(){
dummyGround = new StaticTerrain(assetManager, Vector3f.ZERO, "DummyGround");
rootNode.attachChild(dummyGround.rootNode);
}
private void setupLight(){
AmbientLight ambient = new AmbientLight();
ambient.setColor(ColorRGBA.White);
rootNode.addLight(ambient);
DirectionalLight sun = new DirectionalLight();
sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
sun.setColor(ColorRGBA.White);
rootNode.addLight(sun);
}
private void setupBloom(){
FilterPostProcessor fpp=new FilterPostProcessor(assetManager);
BloomFilter bf=new BloomFilter(BloomFilter.GlowMode.Objects);
fpp.addFilter(bf);
viewPort.addProcessor(fpp);
}
@Override
public void simpleUpdate(float tpf){
cam.setLocation(player.Update(cam.getDirection().clone().multLocal(0.4f),
cam.getLeft().clone().multLocal(0.2f), cam.getRotation(), tpf));
UpdatesTower(tpf);
UpdateEnemy(tpf);
UpdateBuilding();
}
private void UpdateBuilding(){
mainBuilding.Update();
}
private void UpdateEnemy(float tpf){
enemyGenerator.Update(tpf);
listener.setLocation(cam.getLocation());
listener.setRotation(cam.getRotation());
}
private void UpdatesTower(float tpf){
towerGenerator.Update(tpf);
if(player.tower){
player.tower = false;
towerGenerator.addTower(player.physics.getPhysicsLocation(), cam.getDirection().clone());
rootNode.attachChild(towerGenerator.getRootNode());
bulletAppState.getPhysicsSpace().add(towerGenerator.getBodyPhysics());
bulletAppState.getPhysicsSpace().add(towerGenerator.getTurrentPhysics());
for(int i = 0; i < towerGenerator.getTower().getBulletGenerator().bullet.length; i++){
bulletAppState.getPhysicsSpace().add(towerGenerator.getBulletPhysics(i));
}
}
}
}