问题标签 [java.library.path]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
726 浏览

c++ - 杰尼不工作

这是我的 Java 代码。

我正在使用 jdk1.7.0_17 。这是我的 C++ 代码

我使用以下注释运行该程序。

javac NativePrompt.java

javah NativePrompt

g++ -o NativePrompt.so -shared -I /usr/lib/jvm/jdk1.7.0_17/include -I /usr/lib/jvm/jdk1.7.0_17/include/linux NativePrompt.cpp

导出 LD_LIBRARY_PATH='/home/user/jniwork/'

java NativePrompt

现在我收到以下错误。我不知道如何解决它。

线程“主”java.lang.UnsatisfiedLinkError 中的异常:java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860) 处 java.lang.Runtime.loadLibrary0(Runtime.java:845) 处的 java.library.path 中没有 NativePrompt在 java.lang.System.loadLibrary(System.java:1084) 在 NativePrompt.(NativePrompt.java:5)

0 投票
0 回答
398 浏览

maven - Maven 设置 java.library.path

我尝试了其他 stackoverflow 问题中提出的其他答案,但其中一些已经过时或不起作用。我想知道让 Maven 设置 java.library.path 的首选方法是什么?

0 投票
3 回答
22390 浏览

java - System.loadLibrary 不起作用。链中第二个库的 UnsatisfiedLinkError

我有通过 JNI 使用 cpp 共享库 libclient.so 的 java 程序 Client.class。libclient.so 构建为共享并使用 cpp 共享库 libhttp.so。

libclient.so 和 libhttp.so 放在文件夹/home/client/lib64
Client.class 放在/home/client/bin

客户端可以加载库

  1. System.load 和环境变量 LD_LIBRARY_PATH
  2. System.loadLibrary 和 -Djava.library.path

第一种方法效果很好。

export LD_LIBRARY_PATH = /home/client/lib64

java -classpath ./bin 客户端

第二种方式失败。

java -classpath ./bin -Djava.library.path=./../lib64 Client

当我将 libhttp.so 放入 /usr/lib64 时,第二种方法可以正常工作。

如果我使用 System.loadLibrary,为什么 libclient.so 会在 /usr/lib64 中寻找 libhttp.so?如何在不将 libhttp.so 复制到 /usr/lib64 的情况下修复它?

我的加载代码:

附加信息。

如果我用 ldd 测试 libclient.so,我会看到:libhttp.so => not found 如果我设置 export LD_LIBRARY_PATH = /home/client/lib64,那么我会看到:libhttp.so => /home/client/lib64/libhttp.so

0 投票
5 回答
107012 浏览

linux - 如何在 Linux 中将 .so 文件添加到 java.library.path

我正在使用一个需要.dll在 windows 中的 java.library.path 中的文件的 java 应用程序。要在 Linux 中运行相同的应用程序,我有相应的.so文件应该添加到java.library.pathlinux 机器中,到目前为止我没有找到任何简单的解决方案

我确实把它放在了.so一个已经在类路径中的文件夹中,但是我的应用程序仍然抱怨没有所需.so的文件java.library.path

我想找到:

  1. 添加.so方法java.library.path
  2. 如何知道它是否已经添加(添加时)
0 投票
1 回答
3591 浏览

hadoop - Hadoop 和 JZMQ - java.library.path 中没有 jzmq

我试图让 JZMQ 代码在 Hadoop 集群上的一个节点上运行。我在该节点的 /usr/local/lib 目录下安装了必要的本机 jmzq 库文件。

这是列表 - libjzmq.a libjzmq.la libjzmq.so libjzmq.so.0 libjzmq.so.0.0.0 libzmq.a libzmq.la libzmq.so libzmq.so.3 libzmq.so.3.0.0 pkgconfig

在我的 shell 脚本中,如果我运行下面的 Java 命令,它绝对可以正常工作 -

但是当我运行下面的命令时,它会在线程“main”中抛出异常

我使用 Export 命令在 Hadoop Classpath、Opts 等中明确设置了必要的文件/Jars

源代码 JAR 和 jzmq-2.1.3.jar 文件位于 Hadoop 节点上的 /home/txtUser/analytics/lib/ 文件夹下。此外,/usr/local/lib 被添加到系统 ld.conf

任何人都可以建议,给出我在这里可能做错的输入吗?

0 投票
1 回答
350 浏览

java - java.library.path 在 Linux 上运行时放错位置

在运行时设置 java.library.path 不会做任何事情:

我像这样运行测试(之前已经构建过):

输出是:

我究竟做错了什么?这发生在其他人身上吗?

另外,我尝试在命令行中设置它,结果相同:

0 投票
0 回答
1329 浏览

linux - Linking native hidapi and libusb-1.0 library in eclipse on Ubuntu

I am new to Ubuntu and searched on-line for two days, tried a lot of solutions but do not have any luck yet. If anyone can help with this, I will appreciate.

I wrote a program in Java with eclipse on Windows. My program makes use of Java hidapi library, which is a Java wrapper of the C version hidapi library (.dll). In eclipse, by adding the Java hidapi to the build path and setting the C hidapi as a native library, everything works just fine.

Now I want to do the same on Ubuntu. The same Java hidapi is used, which now will make use of the C version hidapi library for Linux (a .so file). When making the C version hidapi library for Linux, it turns out that I need another library called libusb-1.0 (which hidapi needs to deals with the low level communication). So I install libusb-1.0 (now I have a libusb-1.0.so file under /usr/lib/i386-linux-gnu), make the C version hidapi library for Linux. I have a small C program and I test it under bash, it works so I believe until this point everything, both libsub-1.0.so and C version hidapi library for Linux libhidapi-jni.so are installed/generated correctly, and when running the small C program the system is able to find the shared libusb-1.0.so library without explicitly mentioning where libsub-1.0 is (which makes sense because libusb-1.0 is installed in a place where the system loader will always search).

So I go to eclipse. I import the eclipse work space, add the Java hidapi to the build path (as I did in Windows), move the C version hidapi library for Linux (the .so file) into a folder called 'lib' (where the .dll version of native library also resides). And I set the native library to 'lib', by "build path" -> "configure build path" -> "libraries" tab -> "native library location". So till this point, the two native libraries are: libusb-1.0 under /usr/lib/i386-linux-gnu, and hidapi.so under 'wherever eclipse workspace is'/lib. Finally in the source code I add two lines:

System.loadLibrary("usb-1.0"); // Call this line A.

System.loadLibrary("hidapi-jni"); // Call this line B.

I run the program as a Java application. It reports "java.lang.UnsatisfiedLinkError: no usb-1.0 in java.library.path" at line A. So I guess the Java runtime is not able to find where libsub-1.0 is.

Just for clarification, I already did the following trials, none of them worked.

  1. Remain the two libraries where they are, add vm argument (Run -> Run Configuration -> Arguments -> VM arguments): -Djava.library.path="${workspace_loc:project_name}/lib; /usr/lib/i386-linux-gnu". It gives: "java.lang.UnsatisfiedLinkError: no usb-1.0 in java.library.path" at line A.
  2. Undo 1. Move libsub-1.0.so to 'wherever eclipse workspace is'/lib, so now the two .so files are together. Set .jar's native library location to this folder. It gives "java.lang.UnsatisfiedLinkError: blablabla: undefined symbol: libusb_control_transfer" at line B. So I think it founds the libusb library, however the symbol (which should be in libusb) is still unresolved. This is really weird.

Can anyone help me? Thanks in advance.

0 投票
23 回答
525284 浏览

java - Hadoop“无法为您的平台加载本机 hadoop 库”警告

我目前正在运行CentOs的服务器上配置 hadoop 。当我运行start-dfs.shorstop-dfs.sh时,我收到以下错误:

WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... 在适用的情况下使用内置 java 类

我正在运行Hadoop 2.2.0。

在线搜索出现了这个链接:http ://balanceandbreath.blogspot.ca/2013/01/utilnativecodeloader-unable-to-load.html

但是,/native/hadoop 2.x 上的目录内容似乎有所不同,所以我不确定该怎么做。

我还在以下位置添加了这两个环境变量hadoop-env.sh

导出 HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=/usr/local/hadoop/lib/"

导出 HADOOP_COMMON_LIB_NATIVE_DIR="/usr/local/hadoop/lib/native/"

有任何想法吗?

0 投票
3 回答
53325 浏览

java - 默认Java库路径?

我知道您可以-Djava.library.path=/path/to/libs在执行程序之前使用选项 ( ) 设置 Java 库路径,但是如果您不手动设置,系统上是否有 Java 看起来的地方?

0 投票
0 回答
329 浏览

android - Appcelerator Titanium 无法在我的 Mac 上启动

我试图在我的 Mac 上运行 appcelerator Titanium Studio,但它给了我这个错误(我已经删除并重新安装了 TitaniumStudio.app、java、workpspace 目录..)

我的操作系统是 Osx Mavericks,jdk-7u45,Titanium studio (3.2.0) 的最新版本

有什么建议么?谢谢!