[read here 1st]
I had done that and it did not work.
Java seems to “try to help us” more than we may want…
But I found the solution!
For anyone else having this kind of problem, not being able to use the native bullet for example:
The problem is quite simple, jars not specified with -classpath
are being found and loaded!!!
First of all, add this to your JVM run/debug argument -verbose:class
.
That promptly showed here that jme3-jbullet.jar
was being loaded despite not present at the -classpath
parameter !!!
That was the reason it was throwing that ununderstandable exception here, because that jar was requesting for jbullet.jar
that I had physically removed/deleted.
Add this code Thread.currentThread().getContextClassLoader()
and read thru the returned object, it will show not required jars that got loaded and a lot of more interesting info.
LINUX only:
Well, continuing… so, I am using Linux, and it allows for symlinks.
It is clear that symlinks are getting resolved to their canonical real absolute file path.
So a symlink like:
/selectedLibs/jme3-bullet.jar -> /fullLibsStorage/jme3-bullet.jar
was being resolved to
/fullLibsStorage/jme3-bullet.jar
,
and all jars at /fullLibsStorage/
(and also recursively because jars on sub-dirs were being loaded too) were being added even if not specified at -classpath
!!!
To exemplify:
cd "/home/$USER/temp/tstjava"
There is the compiled class for this source code here: ./tests/BulletTest.java
java -verbose:class -classpath ./:jME3.1-beta1/jMonkeyEngine3.jar tests.BulletTest
The file jme3-jbullet.jar
was present at ./jME3.1-beta1/lib/
but not specified at the -classpath
above!
This unwanted jar showed at the console output:
[Loaded com.jme3.bullet.PhysicsSpace from file:/home/$USER/temp/tstjava/jME3.1-beta1/lib/jme3-jbullet.jar]
!!!
Final tip:
Make it sure to physically remove non required or conflicting jars.
Alternatively their extension can be simply renamed.
PS.: could this be some configuration at my environment, or for Linux, that allows/requests for searching for jars not specified with -classpath
? or is this behavior widely spread, happening also at Windows and Mac?
Useful link: http://stackoverflow.com/questions/2548384/java-get-a-list-of-all-classes-loaded-in-the-jvm