Youssef wrote:
Before thinking to build and call directly my native code, my java
classes called directely
NSDistributedNotificationcenter constructor (deprecated since i
don't found an other class replacing it, this is an other
headache ). but this constructor throw this exception:
NSRuntime.loadLibrary(/usr/lib/java/libObjCJava.dylib) error.
java.lang.UnsatisfiedLinkError: /usr/lib/java/libObjCJava.A.dylib:
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1702)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1005)
at com.apple.cocoa.foundation.NSRuntime.loadLibrary(NSRuntime.java:
127)
at com.apple.cocoa.foundation.NSRuntime.<clinit>(NSRuntime.java:35)
at com.apple.cocoa.foundation.NSObject.<clinit>(NSObject.java: 27)
the same error that i have had when cc commandline generated 32-bit
by default rather than 64-bit.
From this error, I think that calling
NSDistributedNotificationcenter ,automatically calls
libObjCJava.dylib and found
that this lib is for 32-bit architecture only.
The com.apple.cocoa classes are part of the Cocoa-Java API, and are
not
supported moving forward from 10.4, when they were deprecated. Since
64-bit Java is a move forward, there are no 64-bit Cocoa-Java classes.
If you want to use 64-bit Java, you must remove all the Java code that
refers to any com.apple.cocoa class. After you do that, the
NSRuntime.loadLibrary() java.lang.UnsatisfiedLinkError will go away.
You do not need to link your 64-bit JNI-lib with any lib in /usr/lib/
java.
If you must use Cocoa functions from Java, you have two options:
1) Only run under the 32-bit JVM, so you can call Cocoa-Java.
2) Write a JNI library that calls the native Cocoa functions,
then call that jnilib from your Java class.