jni dans linux(Cent6): Exception in thread “main” java.lang.UnsatisfiedLinkError

Je travaille maintenant avec JNI.

J'ai fait les choses ci-dessous:

  1. J'ai fait HelloJNI.java. Il a simplement bibliothèque de liens libhello.donc.

    static {
      System.loadLibrary("hello");
    }
    

comme ça. bien sûr, j'ai corps aussi, mais rien de spécial.

  1. puis j'ai fait fichier de classe, C fichier et le fichier d'en-tête.
    J'ai commandé

    #javac HelloJNI.java
    #javah -classpath /usr/guest/workspace/path/-jni package.HelloJNI
    no errors till now.
    
  2. J'ai fait libhello.donc.

    # gcc -shared -fpic -o libhello.so -I/usr/java/jdk1.7.0_21/include -I/usr/java/jdk1.7.0_21/include/linux HelloJNI.c
    
  3. Lorsque j'exécute ce projet dans eclipse, message d'erreur s'affiche comme ci-dessous.

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)
        at java.lang.System.loadLibrary(System.java:1084)
        at org.owls.jni.HelloJNI.<clinit>(HelloJNI.java:7)
    

J'ai essayé celui-ci, mais ne fonctionne pas.

    # chcon -t texrel_shlib_t libhello.so

Merci pour votre lecture et votre sage solutions:D

  • quelqu'un parler de CHEMIN de chose. mais je ne comprends pas où mettre cette ligne.
InformationsquelleAutor Juneyoung Oh | 2013-04-26