Do you know an alternative site for RXTX download?
Here's 2 working links :
http://www.jcontrol.org/download/rxtx_en.html
http://java2s.com/Code/Jar/r/Downloadrxtx22jar.htm
Cheers !!
RxTx installation on windows java.lang.NoClassDefFoundError: gnu/io/CommPort
yes it is taken automatically to classpath, but RXTXcomm uses JNI /native external libraries (.so and .dll files), you must provide the path to them when running your program in command line:
java -jar yourprogram.jar -Djava.library.path="PATH_TO_EXTERNAL_LIBRARIES"
for linux:
suppose you unpacked the rxtx.zip to
/home/user/
if you have 32bit x86 platofrm:
PATH_TO_EXTERNAL_LIBRARIES = /home/user/Linux/i686-unknown-linux-gnu/
if you have 64bit x86 platform the it would be:
PATH_TO_EXTERNAL_LIBRARIES = /home/user/Linux/x86_64-unknown-linux-gnu/
for windows:
suppose you downloaded and unpacked it to C:\rxtxt
PATH_TO_EXTERNAL_LIBRARIES = C:\rxtxt\Windows\i368-mingw32\
If you find it cumbersome to do it from command line you can do it from yout code (before opening port via RXTXcomm):
System.setProperty("java.library.path","PATH_TO_EXTERNAL_LIBRARIES");
EDIT:
of course, you must put RXTXcomm.jar in your classpath in addition to all of the above. If running from command line as jar packaged program - yourprogram.jar - inside the jar you must have a META-INF folder that contains MANIFEST.MF with the following entries:
Class-Path: lib/RXTXcomm.jar
Main-Class: pkg.Main
and yourprogram.jar must be in folder which has folder lib in which is RXTXcomm.jar, also
the class with
public static void main(String[] args)
method must be called Main and reside in package named pkg (just replace pkg.Main with whatever you have).
Then you can run your program succesfully and open a serial port if you have one. This approach also eliminates the need to copy anything in jre/lib/ext folder
EDIT^2:
or, if you don't want to pack your program in jar, position yourself in folder which contains the folder pkg and write:
java -cp PATH_TO_RXTX/RXTXcomm.jar -Djava.library.path="PATH_TO_EXTERNAL_LIBRARIES" pkg.Main
(all paths can be relative or absolute)
EDIT^3:
but I would recommend Java Simple Serial Connector instead of RXTXcomm:
- it handles heavy load from multiple threads as opposed to RXTXcomm (tested in production)
- external libraries are packed in jar so there is no need for setting java.library.path
Choosing what native library to load depending on system setup
No, the OSGi native code filtering does not provide that level of dependency for externally sourced packages. Other than trying to include the specific version of your dependency in the bundle as well (which of course wouldn't work with glibc) you can't achieve this through the Native-Code alone.
One alternative is to not use the Native-Code and instead use your bundle to load the fragment code on demand, by using a different name. So you have Linux\Glibc\211 and Linux\Glibc\212, and then based on the runtime of your bundle's startup, can manually call the System.loadLibrary()
yourself.
Importing an OSGI bundle into eclipse
You will need to also install bundles that export these packages into your target platform.
Related Topics
Local_Policy.Jar and Us_Export_Policy.Jar Different with Unlimited Strength VS Default
Create a Shell Script to Run a Java Program on Linux
Httpservletrequest Get JSON Post Data
Converting a String to Hexadecimal in Java
Concurrentmodificationexception for Arraylist
Why Is 08 Not a Valid Integer Literal in Java
Fill an Array With Random Numbers
How to Reproduce a Silently Dropped Tcp/Ip Connection
Find Java_Home and Set It on Rhel
The Full Pathname of a Jdk Installation for Oracle SQL Developer
How to Implement Basic Authentication with Glassfish
How to Build Netty-Transport-Native-Epoll-4.0.32.Final-Linux-X86_64.Jar
From What Linux Kernel/Libc Version Is Java Runtime.Exec() Safe with Regards to Memory
How to Pass an Error Up the Stack Trace in Swift
"Eee Mmm Dd Hh:Mm:Ss Zzz Yyyy" Date Format to Java.Sql.Date
How to Set Classpath in Linux to Let Java Find Jar File