简体   繁体   中英

javax.comm.CommPortIdentifier.getPortIdentifiers() empty on device running Debian 6

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());          
        }
}

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 (eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM