在使用的UnsatisfiedLinkError JNI? [英] UnsatisfiedLinkError when using JNI?

查看:152
本文介绍了在使用的UnsatisfiedLinkError JNI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Java调用程序在Linux操作系统Ubuntu使用JNI的C程序。

我是新来这和我曾试图的 http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html
。我已经创建的.java,.H,.c和.so文件。但是,当我试图运行的程序,我收到以下错误。

异常线程mainjava.lang.UnsatisfiedLinkError中:没有样品1中的java.library.path
    在java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
    在java.lang.Runtime.loadLibrary0(Runtime.java:823)
    在java.lang.System.loadLibrary(System.java:1028)
    在Sample1.main(Sample1.java:13)


解决方案

此异常表明的.so 是不提供给JVM。

添加其中的.so 存在的目录 LD_LIBRARY_PATH 将解决这个问题。如果的.so 依赖于其他的.so 库的目录,其中这些的.so 存在还需要加入 LD_LIBRARY_PATH

I want to call a C program from Java program using JNI in linux ubuntu.

I am new to this and I have tried the sample program given in http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html . I have already created the .java, .h , .c and .so files. But when i tried to run the program I am getting the following error.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no Sample1 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at Sample1.main(Sample1.java:13)

解决方案

This exception is indicating that the .so is not available to the JVM.

Adding the directory where the .so exists to the LD_LIBRARY_PATH will resolve this. If the .so depends on other .so libraries the directories where these .so exist will also need added to LD_LIBRARY_PATH.

这篇关于在使用的UnsatisfiedLinkError JNI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆