issue using Load Library

J

Jothi

Hi,

I am using MAC OSX 10.4 (imac G5).
I am trying to load a JNI library libxxx.jnilib through an applet.
The code is as follows...

System.loadLibrary("xxx");

I compiled, created jar & signed the same. I have placed the
libxxx.jnilib in the /Library/Java/Extensions/ also set
DYLD_LIBRARY_PATH to /Library/Java/Extensions.

I also tried by putting the libxxx.jnilib in
1)
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Libraries/
2) same folder where the java class & html files are present.
3) /usr/lib/java

For all the above cases I am getting following exception..
iMac:/Library/Java/Extensions root# appletviewer Test.htm
JNINetDirect instance created
java.lang.UnsatisfiedLinkError:
/Library/Java/Extensions/libNetDirect.jnilib:
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1495)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at JNINetDirect.init(JNINetDirect.java:32)
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:552)

The same code if I make it as Java Application it is running
fine....Any idea?
Please help me regarding this...

Regards,
Jothi
 
G

Gordon Beaton

I am using MAC OSX 10.4 (imac G5).
[...]
System.loadLibrary("xxx");

[...]

For all the above cases I am getting following exception..
iMac:/Library/Java/Extensions root# appletviewer Test.htm
JNINetDirect instance created
java.lang.UnsatisfiedLinkError:
/Library/Java/Extensions/libNetDirect.jnilib:
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
[...]

The same code if I make it as Java Application it is running
fine....Any idea?

Was it really necessary to post this to 5 newgroups? Any why do you
think it belongs in an advocacy group? If you really think you need to
post to more than one group, at least learn to *crosspost* properly
and try to show some restraint.

Some questions for you:

1. Is the name of the library really libxxx.jnilib, or is it
actually libNetDirect.jnilib? Please don't obfuscate the
library name if that's what you're doing, it makes it harder
to interpret the error message. Which library is failing?

2. What is the value of java.library.path
a: when it works
b: when it doesn't

3. Does it work if you use

System.load("/actual/path/to/library/libxxx.jnilib");

instead? (I don't suggest this as a solution, but the answer
may help to find out why it's failing)

4. Does the library have runtime dependencies on other libraries?

/gordon
 
A

Andrew Thompson

Jothi said:
I am using MAC OSX 10.4 (imac G5).
I am trying to load a JNI library libxxx.jnilib through an applet. ....
For all the above cases I am getting following exception..
iMac:/Library/Java/Extensions root# appletviewer Test.htm
JNINetDirect instance created
java.lang.UnsatisfiedLinkError: ....
The same code if I make it as Java Application it is running
fine....Any idea?

Security? What security environment does the Macintosh
Applet Viewer impose?

Do you swallow exceptions?
<http://www.physci.org/codes/javafaq.jsp#stacktrace>

I suspect you have a SecurityException/AccessControlException
causing the UnsatisfiedLinkError, hidden somewhere in the code
you did not show..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,821
Messages
2,569,725
Members
45,511
Latest member
Osiris-Team

Latest Threads

Top