Pages: [1]   Go Down
Author Topic: How to programmatically load librxtxSerial in Java  (Read 683 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I started to play with arduino an interfacing it with Java, it was pretty straightforward, but now I would like to programmatically load the librxtxSerial native lib, and I can't figure out.
Since I'm on MacOS 64bit and use Java6 I used the following jnilib : as recommended here :

After that I tried to load it programmatically like this :
  * Loads the jnilib
public static void loadJniLib() {
// loads the jnilib from the source folder "src/main/resources"
URL url = Demo.class.getResource("/librxtxSerial.jnilib");
try {
catch (UnsatisfiedLinkError unsatisfiedLinkError) {
// native code library failed to load.

Which seems to works (at least does not throw an exception).

But when I call the CommPortIdentifier.getPortIdentifier(PORT_NAME); it throws the following exception:
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
at java.lang.ClassLoader.loadLibrary(
at java.lang.Runtime.loadLibrary0(
at java.lang.System.loadLibrary(

So I do not understand what's wrong, since it seems to be the right way to load it according to :

Any idea?

PS : You can find the whole code here : which works provided the rxtx jar is in the classpath and the native library location is defined (like this in Eclipse :

Pages: [1]   Go Up
Jump to: