JMagick 尝试加载文件时出错 - UnsatisfiedLink
java.lang.UnsatisfiedLinkError:java.library.path中没有JMagick 在 java.lang.ClassLoader.loadLibrary(ClassLoader.java:1754) 在 java.lang.Runtime.loadLibrary0(Runtime.java:823) 在 java.lang.System.loadLibrary(System.java:1045)
尝试使用代码时,
ImageInfo info;
try {
info = new ImageInfo();
//image = new MagickImage(info);
} catch (MagickException e) {
logger.error(InsightsHelper.getStackTrace(e));
}
有什么想法为什么会发生这种情况吗?我在 OSX 上使用 eclipse
java.lang.UnsatisfiedLinkError: no JMagick in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1754)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
when trying to use the code
ImageInfo info;
try {
info = new ImageInfo();
//image = new MagickImage(info);
} catch (MagickException e) {
logger.error(InsightsHelper.getStackTrace(e));
}
any ideas why this is happening? I'm using eclipse on OSX
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将编译的二进制文件添加到路径中,以便 Eclipse 可以看到它。
首先添加JMagick.jar作为库,然后在项目属性-> Java 构建路径 ->库,单击添加到此项目的 jmagick jar 并编辑“本机库”的位置,在本例中,它将是 libJMagick-6.2.6.dylib 所在的位置,因为这就是您提供的链接说。
You need to add the binaries that you compiled to the path so that Eclipse can see it.
First add JMagick.jar as a library, then in the the project properties-> Java Build Path -> Libraries, you click on the jmagick jar that you added to this project and edit the location for "Native library", which in this case it'll be where libJMagick-6.2.6.dylib is located since that's what the link that you provided says.
简单的答案是 JVM 正在尝试查找 JMagick 使用的本机库,但失败了。要么您根本没有本机库,要么它不是 JVM 正在寻找的地方。
您需要找出“make install”安装本机 DLL 的位置,并告诉 Java 在正确的位置查找它:
如果您从 Eclipse 中启动,请按照 trigoman 的回答中的过程进行操作。
如果您直接或通过脚本从命令行启动,则需要在
java
命令中包含此选项(或等效选项):请注意,这是一个 JVM 选项,必须位于类名之前。
The simple answer is that the JVM is trying to find a native library used by JMagick, and failing. Either you don't have the native library at all, or it is not where the JVM is looking for it.
You need to figure out where "make install" installed the native DLL and tell Java to look for it in the right place:
If you are launching from within Eclipse, follow the procedure in trigoman's answer.
If you are launching from the command line, directly or via a script, then you need to include this option (or the equivalent) in your
java
command:Note that this is a JVM option and has to go before the classname.