我試圖端口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的依賴? –