[英]UnsatisfiedLinkError, but library is in path
I'm a little confused by this error. 这个错误让我有些困惑。 I'm new to Java and the error seems pretty self explanatory, but I've checked my paths (even defined my own) and it still fails to find this library.
我是Java的新手,但错误似乎很容易解释,但我检查了自己的路径(甚至定义了自己的路径),但仍然找不到该库。 Is there something I'm doing wrong?
我做错了什么吗? See directory screenshot and error screenshot below:
请参阅下面的目录屏幕截图和错误屏幕截图:
UPDATE 更新
UPDATE 2 更新2
If I create a new NetBeans project this works fine. 如果我创建一个新的NetBeans项目,则可以正常工作。 Same code and everything.
相同的代码和所有内容。 If I create new IntelliJ project I get this error above.
如果我创建新的IntelliJ项目,则会在上面收到此错误。 I must be missing something in IntelliJ
我一定在IntelliJ中丢失了一些东西
UPDATE 3 更新3
Found the solution. 找到了解决方案。 Adding dependencies is a bit different in IntelliJ.
在IntelliJ中添加依赖项有点不同。 Thanks all for the help.
谢谢大家的帮助。
http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html
Obidisc4j is a .jar file. Obidisc4j是一个.jar文件。 You just dont see its extension in the explorer.
您只是没有在资源管理器中看到其扩展名。 Regular jar files are not loaded by System.loadLibrary.
常规的jar文件不会由System.loadLibrary加载。 They are automatically loaded by the JVM's classLoader.
它们由JVM的classLoader自动加载。
You are using a native library. 您正在使用本机库。 It doen't matter if that library is in the classpath.
该库是否在类路径中并不重要。 There are 4 ways you can make the Java runtime load your shared library at runtime:
有四种方法可以使Java运行时在运行时加载共享库:
Seems like your application is trying to find out a obidisc4j.dll
(for Windows) or obidisc4j.so
(for Linux). 似乎您的应用程序正在尝试查找
obidisc4j.dll
(对于Windows)或obidisc4j.so
(对于Linux)。 The file must be present on the PATH (but not the classpath). 该文件必须存在于PATH中(而不是类路径中)。 If you are not sure what PATH is your Java application searching in, you can write the following statement, before the point where the exception takes place, to find out the PATH.
如果不确定Java应用程序在搜索哪个PATH,则可以在发生异常之前编写以下语句来查找PATH。
System.out.println(System.getProperty("java.library.path"));
This will tell you about the paths where your DLL or SO file should be placed. 这将告诉您有关放置DLL或SO文件的路径。 You just need to place the file in ONE of those N-paths.
您只需要将文件放在这些N路径之一中即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.