How does the JVM find Native functions?

Mario Torre neugens at limasoftware.net
Wed Jan 26 07:21:05 UTC 2011


Il giorno mar, 25/01/2011 alle 22.28 -0600, John J. Boyer ha scritto:
> I have created bindings for a C library. The Java program seems to load 
> the library, but when I try to use a method which is declared native I 
> always get UnsatisfiedLinkError. I used javah to create the headings, 
> then derived the program from the headings. It looks to me like the 
> methods have to be registered in some way. How do I go about this? How 
> does the JVM find the native function corresponding to a native method?
> 
> Thanks,
> John
> 

Hi John,

Try passing -Djava.library.path=/path/to/your/library.so

Then use System.loadlibrary or System.load in a static initlialiser
where your code is used to register the library.

Cheers,
Mario
-- 
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

Proud GNU Classpath developer: http://www.classpath.org/
Read About us at: http://planet.classpath.org
OpenJDK: http://openjdk.java.net/projects/caciocavallo/

Please, support open standards:
http://endsoftpatents.org/




More information about the discuss mailing list