Deploying JAVA with RXTX

From Rxtx

Jump to: navigation, search

Saving the RXTX jar-file and DLL in the JRE is not optimal if you indend to distribute your JAVA application and do not want to bundle it with a customized JRE.

Contents

Windows

For Windows, the Janel JAVA launcher can be used.

  • create a directory for your application, and save the Janel executable and lap-file to it;
  • create a subfolder named "classes" and save the jar-file of your application as well as the RXTXcomm.jar in it;
  • create a subfolder named "lib" and save the rxtxSerial.dll to it;
  • make the following entries in the lap-file:
    • "-Djava.class.path=;${SELF_HOME}\classes\YourApp.jar;${SELF_HOME}\classes\RXTXcomm.jar;"
    • "janel.main.class=YourAppMainClass"
    • "janel.library.path.dir=${SELF_HOME}\lib"

Simpler approach for Windows

Using a simpler approach (confirmed to work when using NetBeans or Borland JBuilder):

  • Add RXTXcomm.jar as a library
  • compile (build) your application
  • add the rxtxSerial.dll to the root of the distribution folder (*projectname*/dist when using NetBeans)

Simpler approach for Linux

Using a simpler approach (confirmed to work when using NetBeans):

  • Add RXTXcomm.jar as a library
  • compile (build) your application
  • add the librxtxSerial.so to the root of the distribution folder (*projectname*/dist when using NetBeans)

For Ubuntu simply installing librxtx-java package is enough.

unjar

It should be possible to unjar the RXTXcomm.jar and then add the .classes into YourApp.jar. This should eliminate the secon .jar and the need to modify java.class.path. Please clarify the steps if you pursue this.

I was successful in doing this on my Mac. First, unzip the RXTX.jar file. I didn't try unjar, as unzip worked fine. Then, place the gnu folder in the same folder as your application jar file. Execute the following command from the command line:

jar uvf Your_Apps_Name_here.jar gnu

to update the jar with the contents of the classes in the gnu folder. Your app will now run by double clicking on it, provided the .dll or .jnilib library is in the same folder. I would love to include the OS specific libraries in the jar for a single, monolithic package, but after researching this on the web, it is apparently very difficult at best and probably impossible.

Other Platforms

It would be great if someone with access to Linux boxes could provide us with similar recipes for their operating system.

The above unjar instructions and subsequent jars worked fine for my app on both Mac and Windows machines.

The unjar instruction (putting gnu folder in bin path which I use in Eclipse as workdir) worked for me on Ubuntu Linux 11.04 , make sure the librxtx library is installed: the package like described in the wiki here, or the binaries. Use 2.2, not 2.1.

Personal tools