Coach Thrasher

Thursday Sep 15, 2005

Java Communications API Notes

I had tried to get RXTX to work with the old Sun Solaris native drivers with no luck. I don't know if the problem was due to my use of JDK 1.5.0, or my os, or my fumbling. In any event, Sun has updated their communications api to version 3, and they've released a Linux/Solaris version. If in doubt, install the latest version?... we'll see.

Here are the notes from my install of Sun's Java Communications API (for Linux). I was successful quite quickly, so hopefully these will be useful to others.

My starting platform:

  1. Fedora Linux Core 3
  2. Sun's Java SDK, v1.5
  3. Tyan Tiger MPX mainboard with two known-working serial ports

Installation:

  1. Download the API
  2. unpack the download:
    unzip comm3.0_linux.zip
  3. read, but don't execute, the linux instructions:
    firefox commapi\docs\html\platform\linux\PlatformSpecific.html
  4. install the library:
    cp commapi/lib/libLinuxSerialParallel.so 
    JAVA_HOME/jre/lib/i386/libLinuxSerialParallel.so
  5. install the jar:
    cp commapi/jar/comm.jar 

    JAVA_HOME/jre/lib/ext/comm.jar

Now that the API has been installed, we can run the BlackBox test:


mkdir test

cd test

cp ../commapi/jar/tools/BlackBox.jar .

cp ../commapi/docs/portmap.conf_example.txt portmap.conf

cp ../commapi/docs/javax.comm.properties .

export CLASSPATH=.:BlackBox.jar

java -Dprops BlackBox

At this point, if you are logged into linux locally, or of you are working over an ssh session with X11 port forwarding turned on (cygwin), you should see a window popup with a serial port gui. My motherboard has two serial ports, and the gui has matching sections for each.

WARNING: If your serial ports are currently being used by another application (maybe your UPS?), Java will kick the other app off of the port, and take ownership on it's own. This is a known feature of the API, see it's documentation for details.

On another note, I tried following Sun's installation instructions, but I kept getting the error:


javax.comm:  Error loading javax.comm.properties!

null



java.io.IOException: javax.comm: platform driver class name = null

                     (Check 'driver' property in javax.comm.properties)



        at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:243)

        at javax.comm.CommPortIdentifier.(CommPortIdentifier.java:109)

        at BlackBox.main(Unknown Source)

implementation version = 3.0

javax.comm.properties  = null

portmap.conf           = null

Driver class name      = null

Exception in thread "main" java.lang.UnsatisfiedLinkError: isSessionActive

        at com.sun.comm.SunrayInfo.isSessionActive(Native Method)

        at com.sun.comm.Portmapping.registerCommPorts(Portmapping.java:155)

        at com.sun.comm.Portmapping.refreshPortDatabase(Portmapping.java:100)

        at javax.comm.CommPortIdentifier.(CommPortIdentifier.java:138)

        at BlackBox.main(Unknown Source)

It appears that the javax.comm.properties file was not being found. It finds it just fine if it's in the local directory and classpath, but not when it is installed to
JAVA_HOME/jre/lib per Sun's docs.

I also found that the portmap.conf file needs to live in the local directory and classpath. This file is not mentioned in Sun's API install notes.







Comments:

3Q for U experience, i am sorry because of my poor english.i built the Applet for bankbook printer in windows(javax.comm.jar 2.0),it's fine but error when i change it to javax.comm.jar 3.0 for linux in RH AS 4.0,it report "error loading javax.comm.properties",i cp javax.comm.properties and portmap.conf to $JAVA_HOME/jre/lib,and cp comm.jar to $JAVA_HOME/jre/lib/ext,then i open firefox to load the applet,but the same error to.would you give some suggestion,thanks~,good day.

Posted by debugger on January 15, 2007 at 03:53 AM PST #

javax.comm: Error loading javax.comm.properties!
null

java.io.IOException: javax.comm: platform driver class name = null
(Check 'driver' property in javax.comm.properties)

at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:244)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at SerialToGsm.<init>(SerialToGsm.java:44)
at SerialToGsm.main(SerialToGsm.java:220)
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.comm.SunrayInfo.isSessionActive()Z
at com.sun.comm.SunrayInfo.isSessionActive(Native Method)
at com.sun.comm.Portmapping.registerCommPorts(Portmapping.java:155)
at com.sun.comm.Portmapping.refreshPortDatabase(Portmapping.java:100)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:138)
at SerialToGsm.<init>(SerialToGsm.java:44)
at SerialToGsm.main(SerialToGsm.java:220)

Posted by arun prabhath on May 20, 2009 at 03:30 AM PDT #

I also got the above error posted by myself. Please give me a solution

Posted by arun prabhath on May 20, 2009 at 03:31 AM PDT #

java -cp comm.jar:commtest.jar:. SerialToGsm
this is how I attempted to run the java code

Posted by arun prabhath on May 20, 2009 at 03:33 AM PDT #

I recently came accross your blog and have been reading along. I thought I would leave my first

comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep

visiting this blog very often.so you also can read my website,if you like

Posted by cheap ugg boots on December 24, 2009 at 07:26 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Calendar

Feeds

Search

Links

Navigation

Referrers