如何解决“ java.lang.unsatisfiedlinkerror”在MAC终端?
我有一个jar文件“ myapp.jar”,我需要通过命令行运行。当我在Linux服务器上运行JAR时,它可以正常工作。但是,当我尝试在Mac终端上使用同一JAR时,我会收到此错误消息:
Exception in thread "main" java.lang.UnsatisfiedLinkError: while loading kognac-core: Stream closed
at karmaresearch.vlog.VLog.loadLibrary(VLog.java:72)
at karmaresearch.vlog.VLog.<clinit>(VLog.java:22)
at org.semanticweb.rulewerk.reasoner.vlog.VLogReasoner.<init>(VLogReasoner.java:82)
at org.semanticweb.rulewerk.client.picocli.MyApp.someMethod(MyApp.java:150)
at org.semanticweb.rulewerk.client.picocli.MyApp.main(MyApp.java:110)
我用来运行jar的命令是:
java -jar myApp.java
jar文件是由javase-1.8
通过eclipse编译和创建的。在Mac上。 Linux服务器的Java版本是OpenJDK版本“ 1.8.0_292”
Mac上的Java版本为3:Java SE 11.0.1
(默认版本),1.8.0_202
,1.8.0_201
by the Commands:
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java -jar myApp.java
/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/bin/java -jar myApp.java
我尝试使用所有3个Java版本在Mac上运行JAR文件,但上面仍然遇到相同的错误。
如何在Mac终端上解决此错误?
I have a jar file 'myApp.jar' that I need to run through command line. When I run the jar on linux server it working perfect. However, when I tried to the same jar on mac terminal I am getting this error message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: while loading kognac-core: Stream closed
at karmaresearch.vlog.VLog.loadLibrary(VLog.java:72)
at karmaresearch.vlog.VLog.<clinit>(VLog.java:22)
at org.semanticweb.rulewerk.reasoner.vlog.VLogReasoner.<init>(VLogReasoner.java:82)
at org.semanticweb.rulewerk.client.picocli.MyApp.someMethod(MyApp.java:150)
at org.semanticweb.rulewerk.client.picocli.MyApp.main(MyApp.java:110)
The command that I used to run the jar is:
java -jar myApp.java
The jar file is compiled and created by javaSE-1.8
through Eclipse on Mac.
The java version of Linux server is openjdk version "1.8.0_292"
The java versions on Mac are 3: Java SE 11.0.1
(default version) , 1.8.0_202
, 1.8.0_201
by these commands:
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java -jar myApp.java
/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/bin/java -jar myApp.java
I tried to run the jar file on mac with all 3 java versions, but still getting the same error above.
How could I resolve this error on Mac terminal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题与您的应用程序无关或如何运行它。
您的应用程序使用
karmaresearch
我不熟悉的项目(可能是您/您的团队写的代码 所谓的本机库:这些是为OS/架构编译的库,您的JVM在顶部运行。这些以Mac上的
.jnilib
文件的形式,.dll
在Windows上以及Linux和其他基于Posix的OS上的.SO
。本地图书馆非常令人难以置信的货物:您需要1个这样的文件,以实现OS和基础架构的每个组合。因此,如今,您最少需要提出合理的声称:
,这只是裸露的骨骼。
加载这些文件时,这些文件不能在罐子内。通常的过程是获取一个可以写入和加载代码(棘手)的位置,请为该文件夹解开正确的文件,然后
load> loadLibrary
它。这都是非常复杂的。通常,要么[a]您写了karmaresearch,因此您需要首先考虑使用本机库,如果您真正需要它,请遵循教程,或者[b]不是您的代码,在这种情况下,您可以' t完全在Mac上运行此操作,除了与此库的制造商联系并要求他们为此增加支持之外,您无能为力。The problem isn't related to your app or how you run it.
Your app uses the
karmaresearch
project which I'm not familiar with (possibly, that's your own code, that you / your team wrote?) and this code attempts to load a so-called native library: These are libraries compiled straight for the OS/architecture your JVM is running on top of.These take the form of a
.jnilib
file on mac,.dll
on windows, and.so
on linux and other posix-based OSes.Native libraries are incredibly convoluted to ship: You need 1 such file for each combination of OS and underlying architecture. So, these days, you'd need at a minimum to make a reasonable claim that you're 'portable':
and that's just a bare bones minimum.
These files cannot be inside the jar when you load them. The usual procedure is to obtain a location you can write to and load code out of (tricky), unpack the right file for the host OS to this folder, and then
loadLibrary
it. This is all very complicated. In general, either [A] you wrote karmaresearch and you need to think long and hard about using native libraries first, and if you truly need it, follow a tutorial, or [B] it's not your code, in which case you can't run this on a mac, at all, and there's nothing you can do about that, other than contact the makers of this library and ask them to add support for this.