如何使用OSGi Equinox设置rxtx? [英] how to set rxtx with OSGi Equinox?
问题描述
我正在寻找解决问题的方法.
我正在开发一个必须通过rxtx jar从串行端口读取的包.
启动应用程序时,出现以下错误
I am looking for a solution to my problem.
I am developing a bundle that has to read from the serial port by means of rxtx jar.
When I launch the application, I get the following error
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:123)
at ez430.Port.<init>(Port.java:29)
我已经添加了jar来构建路径并将其设置在jVM中.
I have added the jar to build path and set it in the jVM.
请帮助我!
推荐答案
由于OSGi是多平台的,需要照顾捆绑包的出现和消失,因此需要明确指定本机库的处理方式(如rxtx一样)一束.使用包含rxtx jar文件的捆绑软件中的Bundle-NativeCode
标头可以完成此操作.可以按操作系统和体系结构指示要加载的本机库.在这种情况下,它可能看起来像:
Since OSGi is multi-platform and needs to take care of appearing and disappearing bundles, the handling of native libraries (as rxtx does) needs to be explicitly specified for a bundle. That is done using a Bundle-NativeCode
header in the bundle that includes the rxtx jar file. The native library to load can be indicated per os and architecture. In this case it may look like:
Bundle-NativeCode: lib/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so;
osname="Linux";processor="x86-64",
lib/Windows/i368-mingw32/rxtxSerial.dll;
osname="Windows"
上面的示例表明,对于Linux x86-64,该库可以在lib/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so
中找到,对于Windows(所有体系结构)可以在lib/Windows/i368-mingw32/rxtxSerial.dll
中找到.路径在包中是相对的,因此不要忘记在包中包括共享库.
The above example indicates that for Linux x86-64 the library can be found in lib/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so
and for Windows (all architectures) in lib/Windows/i368-mingw32/rxtxSerial.dll
. Paths are relative in the bundle, therefore don't forget to include the shared libraries in your bundle.
有关更多详细信息,请参见 OSGi核心规范.
For further details, look in the OSGi core specification.
这篇关于如何使用OSGi Equinox设置rxtx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!