4

I have a project in eclipse that uses rxtx. I have the same project in netbeans, too. They work perfectly, but neither of them works, when I create runnable jars.

I do not know what I do wrong. I tried to change classpaths, adding external libraries...

I must be doing something wrong, but can not not figure out what.

If there is out there somebody who managed to get rxtx work, can you explain step-by-step what to do?

dwarfhero
  • 43
  • 1
  • 1
  • 6
  • Could you post an error message or something? – Kai May 23 '13 at 14:33
  • There are no error messages (where should they be written anyway?), I just double click on the jar and nothing happens. I do not know where should those error messages occur, I am just an amateur programmer :) – dwarfhero May 24 '13 at 12:50

1 Answers1

2

See my answer here for a fuller explanation, but essentially you must extract the RXTX dll's (or so's, or other native libraries) from the JAR file and place them somewhere on the file system before you attempt to load them (which in this case involves initialising RXTX.) You cannot load the native libraries from inside the JAR file, it won't work.

However, you can have a JAR file that, when it runs, extracts the appropriate native libraries to a temporary location and then loads them from there. The libraries can be set to delete on exit of the VM so they don't end up clogging up the system.

Community
  • 1
  • 1
Michael Berry
  • 70,193
  • 21
  • 157
  • 216
  • The dll-s are in the same folder as the jar of my program (so they are not in the jar). I copied them later, that is true, but they are there. – dwarfhero May 23 '13 at 17:19
  • It may happen that I did not. The problem is that I never had to deal with classpaths before, and I could not find a normal step-by-step explanation anywhere. I have installed rxtx in the way it was suggested on its wiki page, but unfortunately there were also steps that were not so clear to me. – dwarfhero May 24 '13 at 12:47
  • @dwarfhero It's not a classpath, it's a VM argument. You can use `System.getProperty("java.library.path");` at runtime to determine if it's set correctly. – Michael Berry May 24 '13 at 12:49
  • It said that it uses the standard jre library (which, by the way, includes the rxtxcomm.jar), and of course many other stuff. I guess what I need to achieve is that besides the jre7 and the other things it also uses the rxtx that is NOT in the jre file. Or should I remove rxtx from the jre7 file? Can it cause a problem that it can be found at 2 different places? But what I do not understand is, that if it is in the jre7 file, why it does not want to run? – dwarfhero May 24 '13 at 14:14
  • [Now I was just random clicking in stack owerflow, and came across with jSSC. Now, it does not matter how I manage to solve serial connection (the only criterium is that it should work both on mac and windows), the only thing is, that is should work. I do not know if I can manage to make it work, however, I am afraid, that since it is also an external jar I will have the same problems.] I guess my problem is not with serial connections but with external jar-s, that I can not add correctly. – dwarfhero May 24 '13 at 14:33