java native loadlibrary 无法加载库 - Linux fedora25 java8
java native loadlibrary cannot load the library - Linux fedora25 java8
我正在尝试加载我在系统上编译的动态 C++ 库,以便在 java 中进行包装。我过去曾在 windows 上这样做过,但在这里我很难加载库。这是代码:
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import java.io.File;
public interface libWrapper extends Library {
// String path = "." + File.pathSeparator + "hiddenPath/lib/Dynamic";
// System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + path);
// System.setProperty("java.library.path", path + File.pathSeparator
// + System.getProperty("java.library.path"));
libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"libgtengine.so",
libWrapper.class );
Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
}
我尝试用不同的方法指定库的位置但没有成功:
1) 指定-Djava.library.path=PATHTOLIBRARY
2) 使用 System.setProperty,但这没有成功,因为我无法 运行 代码。我收到一个编译错误,提示找不到函数 setProperty(以及 getProperty):错误:(16, 35) java: expected
3) 将 libgteengine.so 复制到与 libWrapper class.
相同的文件夹中
我怀疑我的库有错误的架构构建?
这是我尝试使用方法 1) 和 3) 加载它时收到的错误消息
java.lang.UnsatisfiedLinkError: Unable to load library 'gtengine': Native library (linux-x86-64/libgtengine.so) not found in resource path ([file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/lib/idea_rt.jar, file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/plugins/junit/lib/junit-rt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/charsets.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/deploy.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/cldrdata.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/dnsns.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/jaccess.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/jfxrt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/localedata.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/nashorn.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunec.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunjce_provider.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunpkcs11.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/zipfs.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/javaws.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jce.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jfr.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jfxswt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jsse.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/management-agent.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/plugin.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/resources.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/rt.jar, file:/home/ycourvoisier/Documents/Development/GitLocalRepo/com-enata-java-math/target/test-classes/, file:/home/ycourvoisier/Documents/Development/GitLocalRepo/com-enata-java-math/target/classes/, file:/home/ycourvoisier/.m2/repository/org/ejml/all/0.30/all-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/core/0.30/core-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/dense64/0.30/dense64-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/denseC64/0.30/denseC64-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/equation/0.30/equation-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/simple/0.30/simple-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar, file:/home/ycourvoisier/.m2/repository/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar, file:/home/ycourvoisier/.m2/repository/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar, file:/home/ycourvoisier/.m2/repository/org/hibernate/hibernate-jpamodelgen/5.1.4.Final/hibernate-jpamodelgen-5.1.4.Final.jar, file:/home/ycourvoisier/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/home/ycourvoisier/.m2/repository/javax/servlet/jsp/javax.servlet.jsp-api/2.2.1/javax.servlet.jsp-api-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/javax/el/el-api/2.2.1-b04/el-api-2.2.1-b04.jar, file:/home/ycourvoisier/.m2/repository/junit/junit/4.12/junit-4.12.jar, file:/home/ycourvoisier/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-dbcp2/2.1.1/commons-dbcp2-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar, file:/home/ycourvoisier/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar, file:/home/ycourvoisier/.m2/repository/org/postgresql/postgresql/9.4.1212/postgresql-9.4.1212.jar, file:/home/ycourvoisier/.m2/repository/org/easymock/easymock/3.4/easymock-3.4.jar, file:/home/ycourvoisier/.m2/repository/org/objenesis/objenesis/2.2/objenesis-2.2.jar, file:/home/ycourvoisier/.m2/repository/org/slf4j/slf4j-simple/1.7.22/slf4j-simple-1.7.22.jar, file:/home/ycourvoisier/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar, file:/home/ycourvoisier/.m2/repository/org/openjdk/jmh/jmh-core/1.17.4/jmh-core-1.17.4.jar, file:/home/ycourvoisier/.m2/repository/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-server/9.4.0.RC1/jetty-server-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-http/9.4.0.RC1/jetty-http-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-io/9.4.0.RC1/jetty-io-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jndi/9.4.0.RC1/jetty-jndi-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-util/9.4.0.RC1/jetty-util-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.4.0.RC1/jetty-maven-plugin-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-api/3.0.3/maven-plugin-api-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-model/3.0.3/maven-model-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-inject-plexus/2.1.1/sisu-inject-plexus-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-artifact/3.0.3/maven-artifact-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-core/3.0.3/maven-core-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-settings/3.0.3/maven-settings-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-settings-builder/3.0.3/maven-settings-builder-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-repository-metadata/3.0.3/maven-repository-metadata-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-model-builder/3.0.3/maven-model-builder-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-aether-provider/3.0.3/maven-aether-provider-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-spi/1.11/aether-spi-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-impl/1.11/aether-impl-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-api/1.11/aether-api-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.4/maven-plugin-tools-api-3.4.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/wagon/wagon-provider-api/1.0-beta-6/wagon-provider-api-1.0-beta-6.jar, file:/home/ycourvoisier/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar, file:/home/ycourvoisier/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.0.RC1/jetty-webapp-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.0.RC1/jetty-xml-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.0.RC1/jetty-servlet-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-quickstart/9.4.0.RC1/jetty-quickstart-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jaas/9.4.0.RC1/jetty-jaas-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-security/9.4.0.RC1/jetty-security-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-plus/9.4.0.RC1/jetty-plus-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jmx/9.4.0.RC1/jetty-jmx-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-annotations/9.4.0.RC1/jetty-annotations-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm/5.1/asm-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm-commons/5.1/asm-commons-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm-tree/5.1/asm-tree-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-server-impl/9.4.0.RC1/javax-websocket-server-impl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-client-impl/9.4.0.RC1/javax-websocket-client-impl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.0.RC1/websocket-server-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.0.RC1/websocket-common-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.0.RC1/websocket-api-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.0.RC1/websocket-client-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.0.RC1/websocket-servlet-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/apache-jsp/9.4.0.RC1/apache-jsp-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/toolchain/jetty-schemas/3.1/jetty-schemas-3.1.jar, file:/home/ycourvoisier/.m2/repository/org/mortbay/jasper/apache-jsp/8.5.4/apache-jsp-8.5.4.jar, file:/home/ycourvoisier/.m2/repository/org/mortbay/jasper/apache-el/8.5.4/apache-el-8.5.4.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/apache-jstl/9.4.0.RC1/apache-jstl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/taglibs/taglibs-standard-spec/1.2.5/taglibs-standard-spec-1.2.5.jar, file:/home/ycourvoisier/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar, file:/home/ycourvoisier/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar, file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/lib/idea_rt.jar])
感谢您的宝贵时间和帮助
编辑
public interface libWrapper extends Library {
static String path = "." + File.pathSeparator + "/home/ycourvoisier/Documents/Development/GitLocalRepo/hydros-mathLibrary/HydrosMathLibraryCode/lib/Dynamic";
static {
System.setProperty( "jna.library.path", path + File.pathSeparator
+ System.getProperty( "java.library.path" ) );
}
libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"libgtengine.so",
libWrapper.class );
}
建议这样做是为了使用 System.setProperty。但是javareturns一个字符的非法开头
EDIT2
这是一个精简版,应该做同样的事情,但这也不起作用。代码中直接指定了路径,所以不会混淆是否提供:
public class Frame {
static {
System.setProperty( "jna.library.path", "/home/NAME/Documents/Development/GitLocalRepo/com-hidden-java-math/src" + File.pathSeparator + System.getProperty( "jna.library.path" ) );
}
public interface libWrapper extends Library {
libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"gtengine",
libWrapper.class );
Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
}
private Pointer ptrToCFrame;
public Frame(String name, int parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist) {
ptrToCFrame = libWrapper.INSTANCE.FrameCstructor( name, parent,
x, y, z, rotX, rotY, rotZ,
vX, vY, vZ, angVx, angVy, angVz,
accX, accY, accZ, angAccX, angAccY, angAccZ,
addToFramelist );
}
}
确保将文件放在 LD_LIBRARY_PATH。
在此处查看示例代码:
https://github.com/mkopsnc/keplerhacks/tree/master/jnijna
如果您决定切换到 JNI,请看这里:
解决库加载问题的方法是改代码(这里我仍然怀疑这样做的正确方法)
public class Frame {
static {
System.loadLibrary( "gtengine" );
}
public static native Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
private Pointer ptrToCFrame;
public Frame(String name, int parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist) {
System.out.println("library: " + System.getProperty( "java.library.path" ));
ptrToCFrame = FrameCstructor( name, parent,
x, y, z, rotX, rotY, rotZ,
vX, vY, vZ, angVx, angVy, angVz,
accX, accY, accZ, angAccX, angAccY, angAccZ,
addToFramelist );
}
}
而且我必须指定库的路径 libgtengine.so.3.7(不是较短的版本 libgtengine.so) 在 LD_LIBRARY_PATH
环境变量中。这是在仔细阅读@mko 成员提供的link(在视频中)后发现的。
这现在造成了其他困难(UnsatisfiedLinkError undefined symbol: XOpenDisplay),我稍后再保留。
谢谢
我正在尝试加载我在系统上编译的动态 C++ 库,以便在 java 中进行包装。我过去曾在 windows 上这样做过,但在这里我很难加载库。这是代码:
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import java.io.File;
public interface libWrapper extends Library {
// String path = "." + File.pathSeparator + "hiddenPath/lib/Dynamic";
// System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + path);
// System.setProperty("java.library.path", path + File.pathSeparator
// + System.getProperty("java.library.path"));
libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"libgtengine.so",
libWrapper.class );
Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
}
我尝试用不同的方法指定库的位置但没有成功:
1) 指定-Djava.library.path=PATHTOLIBRARY
2) 使用 System.setProperty,但这没有成功,因为我无法 运行 代码。我收到一个编译错误,提示找不到函数 setProperty(以及 getProperty):错误:(16, 35) java: expected
3) 将 libgteengine.so 复制到与 libWrapper class.
相同的文件夹中我怀疑我的库有错误的架构构建?
这是我尝试使用方法 1) 和 3) 加载它时收到的错误消息
java.lang.UnsatisfiedLinkError: Unable to load library 'gtengine': Native library (linux-x86-64/libgtengine.so) not found in resource path ([file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/lib/idea_rt.jar, file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/plugins/junit/lib/junit-rt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/charsets.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/deploy.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/cldrdata.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/dnsns.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/jaccess.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/jfxrt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/localedata.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/nashorn.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunec.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunjce_provider.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/sunpkcs11.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/ext/zipfs.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/javaws.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jce.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jfr.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jfxswt.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/jsse.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/management-agent.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/plugin.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/resources.jar, file:/home/ycourvoisier/jdk1.8.0_121/jre/lib/rt.jar, file:/home/ycourvoisier/Documents/Development/GitLocalRepo/com-enata-java-math/target/test-classes/, file:/home/ycourvoisier/Documents/Development/GitLocalRepo/com-enata-java-math/target/classes/, file:/home/ycourvoisier/.m2/repository/org/ejml/all/0.30/all-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/core/0.30/core-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/dense64/0.30/dense64-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/denseC64/0.30/denseC64-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/equation/0.30/equation-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/ejml/simple/0.30/simple-0.30.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar, file:/home/ycourvoisier/.m2/repository/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar, file:/home/ycourvoisier/.m2/repository/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar, file:/home/ycourvoisier/.m2/repository/org/hibernate/hibernate-jpamodelgen/5.1.4.Final/hibernate-jpamodelgen-5.1.4.Final.jar, file:/home/ycourvoisier/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/home/ycourvoisier/.m2/repository/javax/servlet/jsp/javax.servlet.jsp-api/2.2.1/javax.servlet.jsp-api-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/javax/el/el-api/2.2.1-b04/el-api-2.2.1-b04.jar, file:/home/ycourvoisier/.m2/repository/junit/junit/4.12/junit-4.12.jar, file:/home/ycourvoisier/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-dbcp2/2.1.1/commons-dbcp2-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar, file:/home/ycourvoisier/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar, file:/home/ycourvoisier/.m2/repository/org/postgresql/postgresql/9.4.1212/postgresql-9.4.1212.jar, file:/home/ycourvoisier/.m2/repository/org/easymock/easymock/3.4/easymock-3.4.jar, file:/home/ycourvoisier/.m2/repository/org/objenesis/objenesis/2.2/objenesis-2.2.jar, file:/home/ycourvoisier/.m2/repository/org/slf4j/slf4j-simple/1.7.22/slf4j-simple-1.7.22.jar, file:/home/ycourvoisier/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar, file:/home/ycourvoisier/.m2/repository/org/openjdk/jmh/jmh-core/1.17.4/jmh-core-1.17.4.jar, file:/home/ycourvoisier/.m2/repository/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar, file:/home/ycourvoisier/.m2/repository/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-server/9.4.0.RC1/jetty-server-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-http/9.4.0.RC1/jetty-http-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-io/9.4.0.RC1/jetty-io-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jndi/9.4.0.RC1/jetty-jndi-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-util/9.4.0.RC1/jetty-util-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.4.0.RC1/jetty-maven-plugin-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-api/3.0.3/maven-plugin-api-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-model/3.0.3/maven-model-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-inject-plexus/2.1.1/sisu-inject-plexus-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-artifact/3.0.3/maven-artifact-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-core/3.0.3/maven-core-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-settings/3.0.3/maven-settings-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-settings-builder/3.0.3/maven-settings-builder-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-repository-metadata/3.0.3/maven-repository-metadata-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-model-builder/3.0.3/maven-model-builder-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-aether-provider/3.0.3/maven-aether-provider-3.0.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-spi/1.11/aether-spi-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-impl/1.11/aether-impl-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-api/1.11/aether-api-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar, file:/home/ycourvoisier/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.4/maven-plugin-tools-api-3.4.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/wagon/wagon-provider-api/1.0-beta-6/wagon-provider-api-1.0-beta-6.jar, file:/home/ycourvoisier/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar, file:/home/ycourvoisier/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar, file:/home/ycourvoisier/.m2/repository/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.0.RC1/jetty-webapp-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.0.RC1/jetty-xml-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.0.RC1/jetty-servlet-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-quickstart/9.4.0.RC1/jetty-quickstart-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jaas/9.4.0.RC1/jetty-jaas-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-security/9.4.0.RC1/jetty-security-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-plus/9.4.0.RC1/jetty-plus-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-jmx/9.4.0.RC1/jetty-jmx-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/jetty-annotations/9.4.0.RC1/jetty-annotations-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm/5.1/asm-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm-commons/5.1/asm-commons-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/ow2/asm/asm-tree/5.1/asm-tree-5.1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-server-impl/9.4.0.RC1/javax-websocket-server-impl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-client-impl/9.4.0.RC1/javax-websocket-client-impl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.0.RC1/websocket-server-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.0.RC1/websocket-common-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.0.RC1/websocket-api-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.0.RC1/websocket-client-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.0.RC1/websocket-servlet-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/apache-jsp/9.4.0.RC1/apache-jsp-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/toolchain/jetty-schemas/3.1/jetty-schemas-3.1.jar, file:/home/ycourvoisier/.m2/repository/org/mortbay/jasper/apache-jsp/8.5.4/apache-jsp-8.5.4.jar, file:/home/ycourvoisier/.m2/repository/org/mortbay/jasper/apache-el/8.5.4/apache-el-8.5.4.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.jar, file:/home/ycourvoisier/.m2/repository/org/eclipse/jetty/apache-jstl/9.4.0.RC1/apache-jstl-9.4.0.RC1.jar, file:/home/ycourvoisier/.m2/repository/org/apache/taglibs/taglibs-standard-spec/1.2.5/taglibs-standard-spec-1.2.5.jar, file:/home/ycourvoisier/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar, file:/home/ycourvoisier/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar, file:/home/ycourvoisier/Documents/Softwares/ideaIU-2017.1/idea-IU-171.3780.107/lib/idea_rt.jar])
感谢您的宝贵时间和帮助
编辑
public interface libWrapper extends Library {
static String path = "." + File.pathSeparator + "/home/ycourvoisier/Documents/Development/GitLocalRepo/hydros-mathLibrary/HydrosMathLibraryCode/lib/Dynamic";
static {
System.setProperty( "jna.library.path", path + File.pathSeparator
+ System.getProperty( "java.library.path" ) );
}
libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"libgtengine.so",
libWrapper.class );
}
建议这样做是为了使用 System.setProperty。但是javareturns一个字符的非法开头
EDIT2 这是一个精简版,应该做同样的事情,但这也不起作用。代码中直接指定了路径,所以不会混淆是否提供:
public class Frame {
static {
System.setProperty( "jna.library.path", "/home/NAME/Documents/Development/GitLocalRepo/com-hidden-java-math/src" + File.pathSeparator + System.getProperty( "jna.library.path" ) );
}
public interface libWrapper extends Library {
libWrapper INSTANCE = (libWrapper)
Native.loadLibrary(
"gtengine",
libWrapper.class );
Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
}
private Pointer ptrToCFrame;
public Frame(String name, int parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist) {
ptrToCFrame = libWrapper.INSTANCE.FrameCstructor( name, parent,
x, y, z, rotX, rotY, rotZ,
vX, vY, vZ, angVx, angVy, angVz,
accX, accY, accZ, angAccX, angAccY, angAccZ,
addToFramelist );
}
}
确保将文件放在 LD_LIBRARY_PATH。
在此处查看示例代码:
https://github.com/mkopsnc/keplerhacks/tree/master/jnijna
如果您决定切换到 JNI,请看这里:
解决库加载问题的方法是改代码(这里我仍然怀疑这样做的正确方法)
public class Frame {
static {
System.loadLibrary( "gtengine" );
}
public static native Pointer FrameCstructor(String name, long parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist);
private Pointer ptrToCFrame;
public Frame(String name, int parent,
double x, double y, double z,
double rotX, double rotY, double rotZ,
double vX, double vY, double vZ,
double angVx, double angVy, double angVz,
double accX, double accY, double accZ,
double angAccX, double angAccY, double angAccZ,
boolean addToFramelist) {
System.out.println("library: " + System.getProperty( "java.library.path" ));
ptrToCFrame = FrameCstructor( name, parent,
x, y, z, rotX, rotY, rotZ,
vX, vY, vZ, angVx, angVy, angVz,
accX, accY, accZ, angAccX, angAccY, angAccZ,
addToFramelist );
}
}
而且我必须指定库的路径 libgtengine.so.3.7(不是较短的版本 libgtengine.so) 在 LD_LIBRARY_PATH
环境变量中。这是在仔细阅读@mko 成员提供的link(在视频中)后发现的。
这现在造成了其他困难(UnsatisfiedLinkError undefined symbol: XOpenDisplay),我稍后再保留。
谢谢