Native code library problem on Leopard?

I get the following errors when I try to run the "Lesson 1" code from the jME Physics 2 Wiki:



Jan 2, 2008 2:27:00 PM org.odejava.Odejava <clinit>

SEVERE: Native code library (32 and 64 bit library) failed to load: java.lang.UnsatisfiedLinkError: no odejava in java.library.path

java.lang.UnsatisfiedLinkError: no odejava in java.library.path

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753)

at java.lang.Runtime.loadLibrary0(Runtime.java:822)

at java.lang.System.loadLibrary(System.java:993)

at org.odejava.Odejava.<clinit>(Odejava.java:88)

at com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory.getImplementationVersion(OdePhysicsSpace.java:210)

at com.jmex.physics.PhysicsSpace.scanAvailableImplementations(PhysicsSpace.java:370)

at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:339)

at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)

at com.jme.app.BaseGame.start(Unknown Source)

at helloworld.Main.main(Main.java:64)

Jan 2, 2008 2:27:00 PM com.jmex.physics.PhysicsSpace scanAvailableImplementations

WARNING: Failed to use physics implementation 'com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory' due to Exception/Error: java.lang.UnsupportedOperationException: Failed to load natives

java.lang.UnsupportedOperationException: Failed to load natives

at org.odejava.Odejava.init(Odejava.java:125)

at com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory.getImplementationVersion(OdePhysicsSpace.java:210)

at com.jmex.physics.PhysicsSpace.scanAvailableImplementations(PhysicsSpace.java:370)

at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:339)

at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)

at com.jme.app.BaseGame.start(Unknown Source)

at helloworld.Main.main(Main.java:64)

Caused by: java.lang.UnsatisfiedLinkError: no odejava in java.library.path

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753)

at java.lang.Runtime.loadLibrary0(Runtime.java:822)

at java.lang.System.loadLibrary(System.java:993)

at org.odejava.Odejava.<clinit>(Odejava.java:88)

… 6 more

Jan 2, 2008 2:27:00 PM class helloworld.Main start()

SEVERE: Exception in game loop

java.lang.IllegalStateException: No physics implementation was registered nor found!

at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:347)

at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)

at com.jme.app.BaseGame.start(Unknown Source)

at helloworld.Main.main(Main.java:64)

aardvark:dist justincrounds$ java -jar helloworld.jar

Jan 2, 2008 2:47:48 PM org.odejava.Odejava <clinit>

SEVERE: Native code library (32 and 64 bit library) failed to load: java.lang.UnsatisfiedLinkError: no odejava in java.library.path

java.lang.UnsatisfiedLinkError: no odejava in java.library.path

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753)

at java.lang.Runtime.loadLibrary0(Runtime.java:822)

at java.lang.System.loadLibrary(System.java:993)

at org.odejava.Odejava.<clinit>(Odejava.java:88)

at com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory.getImplementationVersion(OdePhysicsSpace.java:210)

at com.jmex.physics.PhysicsSpace.scanAvailableImplementations(PhysicsSpace.java:370)

at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:339)

at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)

at com.jme.app.BaseGame.start(Unknown Source)

at helloworld.Main.main(Main.java:64)

Jan 2, 2008 2:47:48 PM com.jmex.physics.PhysicsSpace scanAvailableImplementations

WARNING: Failed to use physics implementation 'com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory' due to Exception/Error: java.lang.UnsupportedOperationException: Failed to load natives

java.lang.UnsupportedOperationException: Failed to load natives

at org.odejava.Odejava.init(Odejava.java:125)

at com.jmex.physics.impl.ode.OdePhysicsSpace$OdeFactory.getImplementationVersion(OdePhysicsSpace.java:210)

at com.jmex.physics.PhysicsSpace.scanAvailableImplementations(PhysicsSpace.java:370)

at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:339)

at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)

at com.jme.app.BaseGame.start(Unknown Source)

at helloworld.Main.main(Main.java:64)

Caused by: java.lang.UnsatisfiedLinkError: no odejava in java.library.path

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753)

at java.lang.Runtime.loadLibrary0(Runtime.java:822)

at java.lang.System.loadLibrary(System.java:993)

at org.odejava.Odejava.<clinit>(Odejava.java:88)

… 6 more

Jan 2, 2008 2:47:48 PM class helloworld.Main start()

SEVERE: Exception in game loop

java.lang.IllegalStateException: No physics implementation was registered nor found!

at com.jmex.physics.PhysicsSpace.create(PhysicsSpace.java:347)

at com.jmex.physics.util.SimplePhysicsGame.initSystem(SimplePhysicsGame.java:90)

at com.jme.app.BaseGame.start(Unknown Source)

at helloworld.Main.main(Main.java:64)



It looks to me like the native library doesn't work on this machine (MacBook running Leopard). I found this topic over at javagaming.org:



http://www.javagaming.org/forums/index.php?topic=17897.msg140496#msg140496



but I'm not sure if this is the same problem.



Anyone have any ideas on how to fix this?

I'm running leopard and I'm not having any trouble with the native libraries. It seems that java just can't find the native library. More than likely you haven't added the native library to the classpath. What IDE are you using?



Anytime you see a java.lang.UnsatisfiedLinkError exception it usually means the app can't find a required native lib.

Please note that the current cvs version of odejava-jni does not contain mac natives. But jME Physics 2 does. As well does the latest release. So if you are not using odejava-jni from it's own cvs, it is a setup problem on your side (as Haibijon already told you).

Thanks for the quick response!



I'm using the odejava-jni.jar that I built from jmephysics. I put it in /System/Library/Java/Extensions/ (where I've put all the jme jars and such). I'm using NetBeans as my IDE, and it doesn't indicate any problems finding the packages, and I get no build errors, just the crash when I run java -jar helloworld.jar. I haven't had any problems building and running other jme code, just with jmephysics.



Sorry I'm a bit of a java noob so some of this may be RTFM.

Yes have a look into wiki or forum about natives (either specify -Djava.library.path={path_to_jnilibs}, configure your IDE correctly to do that automatically, or copy the jnilibs to your jdk native folder). Copying jars and/or natives into your jdk folders is strongly discouraged (you can find posts about this as well).

irrisor said:
Copying jars and/or natives into your jdk folders is strongly discouraged (you can find posts about this as well).


This is discouraged in particular under Mac OS X. Mac OS X is known to have a poor package system, if you make errors copying those files (or deleting them, if you want to go back to previous situation) it can become really hard to restore original Apple Mac Java installatio.

So, my advise is to install your third party native libraries in user directory and not in the Java JDK system directories.