Forums > Java

Relative path in max.jvm.options -Djava.library.path

October 3, 2009 | 11:48 pm

Hi,

I’m currently building an application which requires some native libraries.
It works well when the native libraries are placed in /Library/Java/Extension but I’d like those libraries to stay in the application folder.

I’ve tried with System.load with the complete path of the jnilib but it doesn’t seem to work : Calling System.load doesn’t throw an exception but calling a class requiring the native libraries does.

It also works when specifying those libraries’s complete path in the max.java.config.txt of the standalone but I have to type their complete path.

So my question is : is it possible to type a relative path in max.java.config in the jvm options ? something like :

max.jvm.option -Djava.library.path={appfolder}/Contents/support/java/native

If not, consider this as a feature request.

Thanks

Léo



Ch
October 10, 2009 | 2:09 am

Hi léo,

I’m not sure I understood everything correctly.

if I remember well, I used to work with jnilib this way :

put the libMyLib.jnilib in myApp.app/Contents/MacOS/support/java/lib/
and then just simply used System.loadLibrary("MyLib");

doesn’t that work? Or are you looking for something else?

Ch


October 11, 2009 | 11:30 pm

Hi Charles,

In fact, it works with some jnilib
but not with the one I’m currently working with (jogl : java open gl binding : http://kenai.com/projects/jogl/pages/Home
I don’t know why but the libraries load fine but I can’t instantiate objects needing them.
Those libs don’t work when placed in the app folder except if I specify their complete path with the option -Djava.library.path.
But it is not possible to know the complete path to this application inside of the max.java.config file.
So I was wondering if I would be possible to replace a kind of key-word in the max.java.config file by the complete path to the app when loading the jvm.

Hope it’s clearer (but I’m not sure)

Léo



Ch
October 12, 2009 | 7:23 am

Hi,

Yes I understood about the relative path, which is a good idea.
But I don’t understand why your lib works fine with the complete path but doesn’t when it is just in Contents/MacOS/support/java/lib/
maybe it is something relative to the jnilib itself?
By the way I’m still working with the (quite old) jogl jnilib
we used at gmem, and got no problem with it (under max 4 in fact. maybe I should test it in a max 5 app).

Charles G.


October 12, 2009 | 7:34 am

Ok, salut ? j’avais pas compris que c’était toi. Comment va ?

Do you manage to load jogl without putting the jnilib in /Library/Java/Extensions with a standalone ?
I don’t.

For me, it didn’t work with jogl 1.1, I doesn’t with jogl 2 neither.
I suspect it is relative to the jnilib itself but I haven’t got any clues how. Do you ?

What’s strange is that I can load the libs via System.load without getting an exception. But then I can’t instantiate any classes of the JOGL API without having a "ClassNotFoundException".
Except when their path is in the java property : java.library.path.

So I tried modifying this property within the java code itself (System.setProperty) before loading the jnilibs but it seems that max jvm instantiation renders my code useless.

So I tried modifying this property in max.java.config and here I am.

Hope I’m getting clearer Wink

léo



Ch
October 12, 2009 | 6:30 pm
Léopold Frey wrote on Mon, 12 October 2009 01:34
Ok, Comment va ?

Do you manage to load jogl without putting the jnilib in /Library/Java/Extensions with a standalone ?
I don’t.

ca va. et toi?

So I just haved look to /Library/Java/Extensions. I got nothing in there, however I found that my libjogl.jnilib is in /usr/lib/java/.
If I remove it, I unfortunately got the error : "java.lang.UnsatisfiedLinkError : no jogl in java.library.path".

So it seems that even my System.load fails.
Sorry if I gave you some hope about that all thing.
I’ll try to investigate one of these days.

Please let us know if you find a nice workaround or something else.

See you,
Charles


October 13, 2009 | 7:02 pm

At least I’m not the only one.

My only option for now is to manually install the jnilib or to make an installer.

Léo


Viewing 7 posts - 1 through 7 (of 7 total)