java.lang.NoClassDefFoundError: org/odejava/Odejava

Hi Guys,



I have just been using jME for my project and need to use collision detections and other physics so am looking to use jmephysics. I ran into couple of problems from the offset and I am just hitting against brick walls(metaphorically :slight_smile: ) so hope you guys can help figure it out:


  1. Currently I am using BaseGame as a superclass and saw the BasePhysicsGame class. PhysicsState is already implemented here so jit would be just easier to extend the BasePhysicsGame. But when I compiled it, it contains 20 errors! Either I am completely losing it or someone has just copied and pasted whole lot from SimplePhysicsGame to BaseGame without giving it much thought. The url I used for BasePhysicsGame is:



    http://wiki.jmephysics.irrisor.net/tiki-index.php?page=BasePhysicsGame



    Technically, the BaseGamePhysics should be just ready to be extended/used without errors like the BaseGame right???




  2. I am not able to use the jmephysics even though I downloaded and integrated it with jME. I get the following errors:

02-Dec-2007 10:39:33 class com.jmetest.physicstut.Lesson1 start() SEVERE: Exception in game loop java.lang.NoClassDefFoundError: org/odejava/Odejava         at com.jmex.physics.impl.ode.OdePhysicsSpace.<init>(OdePhysicsSpace.java:309)         at com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory.create(OdePhysicsSpace.java:198)         at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:330)         at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)         at com.jme.app.BaseGame.start(Unknown Source)         at com.jmetest.physicstut.Lesson1.main(Lesson1.java:103) BUILD SUCCESSFUL (total time: 2 seconds)

I understand that it is unable to locate Odejava and the probable cause is that I have not provided correct link in the VM options. But I have provided the following links and jME works fine and odejava-jni.jar is at this place.

-Djava.library.path="Z:My WorkYear 4JMonkeyEnginejmelib";"Z:My WorkYear 4JMonkeyEnginejmephysicsimplodelib"

I would really appreciate help on both these topics!

Kind Regards,

Dev[code was outdated and removed --------------------------------------------------------------------------------------------------]





2) I am not able to use the jmephysics even though I downloaded and integrated it with jME. I get the following errors:


02-Dec-2007 10:39:33 class com.jmetest.physicstut.Lesson1 start()
SEVERE: Exception in game loop
java.lang.NoClassDefFoundError: org/odejava/Odejava
        at com.jmex.physics.impl.ode.OdePhysicsSpace.<init>(OdePhysicsSpace.java:309)
        at com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory.create(OdePhysicsSpace.java:198)
        at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:330)
        at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)
        at com.jme.app.BaseGame.start(Unknown Source)
        at com.jmetest.physicstut.Lesson1.main(Lesson1.java:103)
BUILD SUCCESSFUL (total time: 2 seconds)



I understand that it is unable to locate Odejava and the probable cause is that I have not provided correct link in the VM options. But I have provided the following links and jME works fine and odejava-jni.jar is at this place.

-Djava.library.path="Z:My WorkYear 4JMonkeyEnginejmelib";"Z:My WorkYear 4JMonkeyEnginejmephysicsimplodelib"



I would really appreciate help on both these topics!

Kind Regards,

Dev

(Reply I wrote to be posted in that old thread  :slight_smile: and got warning while posting that a reply has been posted!!)



I know its not so similar - good that I mentioned in my new seperate thread of BasePhysicsGame  ;)!!! May be it would be more suitable to continue replies in that thread



Ok… Firstly I use netbeans and I have installed this thing 3 times to the word from jme netbeans wiki(twice on my laptop and once on uni pc)!



http://www.jmonkeyengine.com/wiki/doku.php?id=setting_up_netbeans_5.0_to_build_jme_and_jme-physics_2



Secondly are you talking about mentioned the build path that is put in VM options or adding the folder itself?? I have put the classpath exactly in VM Options. It works for jME but doesnt for physics. The path is to odejava-jni.jar right?? I checked it that at that path the odejava-jni.jar does exist. May be I am entering it wrong way. I have done it as below:


-Djava.library.path="Z:My WorkYear 4JMonkeyEnginejmelib";"Z:My WorkYear 4JMonkeyEnginejmephysicsimplodelib"



May be that might be the problems?

Thanks,

Dev

Basics about netbeans and java programming should be found on the net or maybe someone else here can give you some pointers (I don't use netbeans myself, sorry).



BasePhysicsGame in the wiki is pretty outdated (was for jME 0.11 and a similar old jME Physics version). I have removed that code from the wiki. If you want an out-of-the-box solution use SimplePhysicsGame, please. Creating game classes yourself requires some experience with setting up game loops and you should not bother with that if you want to get started. (this applies to states and threads as well)

Hi,



I checked it. Its not netbeans or VM options problem. It has to be something else. I just want to create a decent graphics framework for AI implementation for my project. So far I have been following the flagrush tutorial and have been able to generate a random 3D maze and have a simple box moving in various directions through arrow keys. All I want to do now is have basic physics - collision detection and two characters that animate(i.e. walk and shoot bullets). Once that is done, I can use this to implement path-finding algorithms and AI. It is my project for Masters year so dont have a choice. So would appreciate any help here.



The best case in the "BasePhysicsGame" scenario it seems now is to follow the advice you gave to a previous such thread -

"Simply leave your game class like it was before (no changed superclass), create a PhysicsSpace in initGame (see SimplePhysicsGame) and update it in the update method. The source of SimplePhysicsGame is really short - just have a look at it and incorporate what you need into your game class."



However, I would still appreciate any help figuring out the second "java.lang.noClassDefFoundError" problem…



Thanks,



Dev


Hi,



I was just looking at the org.odejava package to check whether there was an odejava.java in source and subsequently odejava.class in the build but surprise surprise there is none. I have tried updating it with CVS but it does not work.



Is this the cause for the problem as this file is imported in OdePhysicsSpace.java(line 309) and how can it be fixed?



Thanks,



Regards,



Dev

The reason being because it is inside the odejava-jni.jar file in the impl/ode/lib directory… java.lang.noClassDefFoundError always mean that you failed to provide the library in the java.library.path… It is either because you have an incompatible version, (like 64 vs 32 bits or older version or something) or because it is not in the path.

Hi,



Thanks for your reply. I have been playing with it and figured the same. The one thing that I noticed though, if I remove the classpath of jME from VM options then I get a similar error for jME but it doesnt make a difference if I remove the classpath for jmephysics i.e. for some reason it is not acknowledging its classpath or it is incorrect. It cant be incorrect because I have put that exact path in browser window and it opens the location of odejava-jni.jar - presumably that is the file we want to provide the classpath for right??



The curious thing is, if I run the physics tutorials from the actual jME-physics_2 project "com.jmetest.physicstut", they work absolutely fine(may be they run from jars??). But if I work by creating other projects or other files and run the same tutorials it doesnt work. Also, I checked the classpath of the files that I am running(which dont compile) and they are:


Z:My WorkYear 4JMonkeyEnginejmebuild;Z:My WorkYear 4ProjectjME-Physics_2distjME-Physics_2.jar



The actual classpaths that I enter for the new projects I create are as required by the netbeans wiki

Z:My WorkYear 4JMonkeyEnginejmelib;Z:My WorkYear 4JMonkeyEnginejmephysicsimplodelib



May be there is something wrong with the part c) "Create, compile and run your own jME project with jME-Physics 2" second section "Set up your new project" point 2) IV b) from the url below:

http://www.jmonkeyengine.com/wiki/doku.php?id=setting_up_netbeans_5.0_to_build_jme_and_jme-physics_2

Again, thanks, I appreciate the help as I have demonstration next week and I should be coding instead of hitting these walls setting this up - setting up jME was relatively simple...

Regards,

Dev
duenez said:

java.lang.noClassDefFoundError always mean that you failed to provide the library in the java.library.path...

No, no, no! NoClassDefFoundError means you are lacking a jar or class file in the classpath. Missing natives (from the java.library.path) are indicated by an UnsatisfiedLinkError.
hawk2k8 said:

odejava-jni.jar - presumably that is the file we want to provide the classpath for right??

yesss - you need to add odejava-jni.jar to your classpath

Bloody hell… even that did not work… but then I did the simplest of things that I should have done a long time ago - add odejava-jni.jar simply as a library!!! Once I did that the old filepath worked!!! Just dont believe I wasted this much time when it could all have been added so simply!!!



The problem was I checked in the "Libraries" part of my project and there was still no org.odejava.Odejava.class in my jME-Physics_2.jar file. Although I have included odejava-jni.jar in the jME-Physics_2 project(I double-checked it and it is there. Hence all of its tutorials work fine). So no matter what classpaths we provided it would not have worked. So adding it simply to the "libraries" in my project and providing its classpath(that was originally mentioned, without odejava-jni.jar at the end) did the trick.



Many hearty thanks to Irrisor and Duenez for all your help. Now if such situation arises for someone else, at least this thread will contribute something!



Kind Regards,



Dev

Maybe that tut should be updated?

Hi Irrisor,



Would be interested to see if other people have the same problems. If I add jME-Physics_2.jar file then odejava-jni.jar is already added to it and so this should not have been an issue. If this problem occurs to other people for some reason then we can put this standard method of adding odejava-jni.jar directly to the library on "setting up jME and jMEphysics with netbeans" wiki. But we need to wait and see if it was specific to me for some reason or it is common.



Regards,



Dev

hawk2k8 said:

If I add jME-Physics_2.jar file then odejava-jni.jar is already added to it and so this should not have been an issue.


Wrong, the odejava-jni.jar is only added to it within the JMEPhysics project, not any subsequent ones where you are referencing jME-Physics_2.jar.


This problem is a non-problem, but made me think for a while. In the end, the NetBeans tutorial needs to be updated.

I also followed the Netbeans tutorial and everything worked fine, until i got to play with JMEPhysics.

The reason this happens is the following:

When you compile and/or run your jme physics, the odejava-jni.jar is referenced as a library, and everything runs fine.

When you go to your own project however, you are only referencing the jME-Physics_2.jar. Now, you wont get any compile-time errors/warnings regarding the odejava-jni.jar missing, because JMEPhysics is only a library. The compiler assumes the library is fully functional.

Truth is, you havent referenced the JMEPhysics library to the ODE library, and thus you get the ClassNotFound exception.

Updating the tutorial would be a good step :)

regards

Konstantinos