1

I'm afraid this might not strictly be a programming question, but more something I need cleared up to continue my programming.

I am simply trying to write a program to do serial communication, specifically using the javax.comm API and I have succeeded on Win7, but when I run any such program on my device, I get no output. The device is running Debian 6, and it has JDK1.8.0 installed.

In order to run my programs on Win7, I needed to get the API and place the three magic files comm.jar, win32comm.dll and javax.comm.properties in specific folders, but I don't know how to do this on my device.

Does anyone know if I can just put these three files in some arbitrary folders and reference them with a path environment variable?

The code I am trying to run is simply:

package test;
import java.util.Enumeration;
import javax.comm.*;

public class Test { 
    public static void main(String[] args) {
        Enumeration e = CommPortIdentifier.getPortIdentifiers();

        while (e.hasMoreElements()) {
            CommPortIdentifier com = (CommPortIdentifier) e.nextElement();
            System.out.println(com.getName());          
        }
}
Adam Jensen
  • 541
  • 1
  • 10
  • 25
  • I tried using RXTXcomm only to get the same platform incompatibility issues. However, I could get the source and build libraries in this case (as opposed to javax.comm). **If anyone has a solution for javax.comm running on "a ARM-bit platform"**, I am very eager to hear about it. – Adam Jensen May 20 '14 at 06:33

1 Answers1

1

According to http://reprap.org/wiki/JavaComm#Installation_on_Linux you need a number of files:

commapi/jar/comm.jar
commapi/lib/libLinuxSerialParallel.so
commapi/lib/libLinuxSerialParallel_g.so
commapi/docs/javax.comm.properties

"Put the jar file somewhere in your class path (e.g. somewhere like usr/java/j2sdk/jre/lib/ext), the .so files in java's load-library path (on my system that's in /usr/java/j2sdk/jre/lib/i386), and javax.comm.properties "somewhere that java can find it" - on my system, that seems to mean creating a symbolic link to it from the directory in which you're running the project, but there must be an easier way."

You might want to find the source used to build the libraries in case the binaries do not work on your system and compile them yourself.

Clues as to how to do this yourself:

http://www.phidgets.com/phorum/viewtopic.php?f=39&t=3750

https://github.com/rxtx/rxtx.git

wojciii
  • 4,253
  • 1
  • 30
  • 39
  • Thanks a lot for the help. I learned a lot from that wiki, but I reached another dead end. I think you are correct in that I need to build the libraries as I get "... libLinuxSerialParallel.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)" However, the FAQ included with the API has the unfortunate "Sun will not be releasing the source code to reference implementations." So I might have to try something else. – Adam Jensen May 20 '14 at 01:22
  • Updated the answer with some clues. – wojciii May 20 '14 at 09:21
  • I almost forgot about this question. I wasn't able to solve the original problem, but I did end up using [jSSC](https://code.google.com/p/java-simple-serial-connector/) for everything related to serial communication. – Adam Jensen Aug 27 '14 at 00:41