0

I wrote a program to communicate with an arduino using the RXTXcomm.jar. It works in eclipse because I "Added External Jars" in the edit class path option.

I got the tutorial off this website: http://www.drdobbs.com/jvm/control-an-arduino-from-java/240163864. I originally tried running the command on that website to get the RXTXcomm.jar to work without having to use the eclipse work around but I couldnt get it to work (after much time and research). However, now I want to make an .exe out of my program. I used Launch4J to make an .exe and it works but, like before the eclipse work around, the serial communication aspect doesn't work.

I have thought of two fixes, I do not know the plausibility of either however:

1) Some how export my java gui to a jar file that contains the RXTXcomm.jar that was added when using eclipse work around

2) Write a script that I run once to set the computer up that will allow me to use the RXTXcomm.jar

The main goal is to create this .exe and put all the supporting files in a folder with it, with maybe a setup/readme file to get it working on any PC.

Here is my stackup when I run just the [myprogram].jar file:

java.exe -jar [myprogram].jar

java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while
loading gnu.io.RXTXCommDriver
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no rxtxSe
rial 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)
        (AND MORE)

I have very little knowledge of what happens behind the scenes of java, I mostly understand the code only. I think that is why I am having trouble with this.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Ian
  • 21
  • 1
  • 4
  • UnsatisfiedLinkError means, it can not find some *native* library, but the java library (RXTXcomm.jar) is found (it is what is trying to load the native library). the native library will usually be rxtxSerial.dll on windows, or librxtxSerial.so on linux/unix, and either .so or .dylib on mac (not sure about hat on mac though). you should have the correct library for your system (also check 32/64bit) in your library path, which usually includes the CWD. – hoijui Jul 25 '15 at 04:44
  • Ok I have that file, just not anywhere near this exe...kinda forgot about it..., could you tell me what you mean by CWD? Eveerything I have is 32 bit (besides my OS) I am on windows 8.1. fyi – Ian Jul 25 '15 at 13:55

1 Answers1

0

Thank you @hoijui,

I ended up just copying the rxtxSerial.dll to the same directory that the exe is run from and now it works. This directory also includes the RXTXcomm.jar as well. When making the exe in Launch4J I made a custom class path: The "Main Class" I selected the jar I made from eclipse, then for the class path I added:

echo %CD%\RXTXcomm.jar 

and

echo %CD%\rxtxSerial.dll.

I am not sure if this is needed to work but its there and it work so I am not messing with it.

Thanks for the help @hoijui

Ian
  • 21
  • 1
  • 4