Problems calling JNI libraries from JRuby

For rubykeychain - a soon to be released open source project for Mac OS

  • I have a native jni library called “libjkeychain.jnilib” which
    implements two static native methods for the java class JKeyChain that
    access the Mac OS X keychain.

The java class calling into the native code library works perfectly fine
when called from plain Java 5 directly. However, I have problems using
the library indirectly from JRuby 1.1.2

First I tried accessing the class JKeyChain like below but get an error:
irb(main):001:0> include Java
=> Object
irb(main):002:0> require ‘jkeychain.jar’
=> true
irb(main):003:0> include_class ‘ext.jkeychain.JKeyChain’
In JKeyChain
NameError: cannot link Java class ext.jkeychain.JKeyChain

Note that JKeyChain includes an static initializer which loads the
native library and prints the two status lines before NameError. Note
also that the “libjkeychain.jnilib” is in the library path (as well as
in the current dir which is “/xxx/rubykeychain/trunk/ext/jkeychain”.

I also tried to instead include another pure Java class from JRuby which
then in turn calls this class with native methods. In this case I get a
another error “java.lang.UnsatisfiedLinkError:

In other words this is pretty stange. Everthing works from plain Java 5,
but when called through JRuby it does not work??? Anyone with some


  Trænger du til at se det store billede? Kelkoo giver dig gode 

tilbud på LCD TV! Se her