我正在尝试使用javacpp-presets二进制文件从Java访问librealsense库。我该如何使用它们?在github页面上,它表示除了javacpp.jar之外,在我的类路径中的某个位置放置所有所需的JAR文件(opencv * .jar,ffmpeg * .jar等)就足够了。
我使用以下结果运行以下命令:
$ javac -cp javacpp-presets-bin/javacpp.jar:javacpp-presets-bin/librealsense.jar TestConnection.java
$ java -jar javacpp-presets-bin/javacpp.jar TestConnection
Warning: Could not load platform properties for class TestConnection
$ java -cp javacpp-presets-bin/javacpp.jar:javacpp-presets-bin/librealsense.jar:. TestConnection
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniRealSense in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:804)
at org.bytedeco.javacpp.Loader.load(Loader.java:613)
at org.bytedeco.javacpp.Loader.load(Loader.java:530)
at org.bytedeco.javacpp.RealSense.<clinit>(RealSense.java:10)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.bytedeco.javacpp.Loader.load(Loader.java:585)
at org.bytedeco.javacpp.Loader.load(Loader.java:530)
at org.bytedeco.javacpp.RealSense$context.<clinit>(RealSense.java:1566)
at TestConnection.main(TestConnection.java:8)
Caused by: java.lang.UnsatisfiedLinkError: no realsense in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:804)
at org.bytedeco.javacpp.Loader.load(Loader.java:604)
... 8 more
我的工作目录:
.
├── javacpp-bin
├── javacpp-presets-bin
├── TestConnection.class
└── TestConnection.java
感谢任何帮助。
答案 0 :(得分:0)
我应该使用librealsense-platform.jar
$ javac -cp javacpp-presets-bin/javacpp.jar:javacpp-presets-bin/librealsense-platform.jar TestConnection.java
$ java -jar javacpp-presets-bin/javacpp.jar TestConnection
$ java -cp javacpp-presets-bin/javacpp.jar:javacpp-presets-bin/librealsense-platform.jar:. TestConnection