我试图端口OSGi的Java项目。此项目取决于某些第三方JAR(librealsense JavaCPP presets)。我使用Eclipse进行开发。OSGi的API版本不匹配异常问题
我测试使用的是什么,我需要一个子集的配置和惨败。 我用于测试的代码如下:
package testinglibrariesplugin;
import org.bytedeco.javacpp.RealSense.*;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
System.out.println("Hello World!!");
try {
context context1 = new context();
device device = context1.get_device(0);
String devName = device.get_name().getString();
System.out.println(devName);
} catch(Exception e) {
System.out.println(e);
}
}
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!!");
}
}
的MANIFEST.MF:
...
Bundle-ClassPath: src/bundletesting/ffmpeg-linux-x86_64.jar,
src/bundletesting/ffmpeg-linux-x86.jar,
src/bundletesting/ffmpeg-platform.jar,
src/bundletesting/ffmpeg.jar,
src/bundletesting/javacpp.jar,
src/bundletesting/javacv.jar,
src/bundletesting/librealsense-linux-x86_64.jar,
src/bundletesting/librealsense-linux-x86.jar,
src/bundletesting/librealsense-platform.jar,
src/bundletesting/librealsense.jar,
src/bundletesting/opencv-linux-x86_64.jar,
src/bundletesting/opencv-linux-x86.jar,
src/bundletesting/opencv-platform.jar,
src/bundletesting/opencv.jar,
.
build.properties:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
src/bundletesting/ffmpeg-linux-x86_64.jar,\
src/bundletesting/ffmpeg-linux-x86.jar,\
src/bundletesting/ffmpeg-platform.jar,\
src/bundletesting/ffmpeg.jar,\
src/bundletesting/javacpp.jar,\
src/bundletesting/javacv.jar,\
src/bundletesting/librealsense-linux-x86_64.jar,\
src/bundletesting/librealsense-linux-x86.jar,\
src/bundletesting/librealsense-platform.jar,\
src/bundletesting/librealsense.jar,\
src/bundletesting/opencv-linux-x86_64.jar,\
src/bundletesting/opencv-linux-x86.jar,\
src/bundletesting/opencv-platform.jar,\
src/bundletesting/opencv.jar
的jar文件我用的是可下载from my Github repo。
我得到以下错误:
Hello World!!
java.lang.RuntimeException: API version mismatch: librealsense.so was compiled with API version 1.12.1 but the application was compiled with 1.9.6! Make sure correct version of the library is installed (make install)
由于代码的工作只使用Java的我必须假设有在Eclipse/OSGi的配置问题。我想忽略这个API不匹配,但我在这个环境中并不是很有经验,我不知道如何继续。如果这不是解决问题的正确方法,请告诉我。
任何帮助表示赞赏。
编辑:这是我在一个普通的Java应用程序中使用的代码和工作原理:
import org.bytedeco.javacpp.RealSense.*;
public class Main {
public static void main(String[] args) {
context context = new context();
device device = context.get_device(0);
String devName = device.get_name().getString();
System.out.println(devName);
}
}
输出:Intel RealSense SR300
预期。
编辑2:我将我的build.properties和清单文件
你确定这个问题是OSGi相关?如果您在简单的Java应用程序中使用简单的主要方法运行代码,会发生什么情况? –
我试着和它完美的作品... – mattdibi
你在这两种情况下使用相同的API的依赖? –