The Java Class For Serial Ports
Demo Version 3.7
Win95, WinNT, OS/2, Mac PPC
Solaris Sparc, Solaris x86, Linux x86, FreeBSD x86, HP/UX PA-RISC, Irix MIPS, AIX PPC (~177 kb)

The Java SerialPort class provides access to the serial ports of the computer allowing you to communicate with barcode readers, modems, mice, printers, sensors, or any serial device.

Demonstration Targets

The SerialPort class (the purchased version) works with Applications on JDK1.0.2 and JDK1.1.x and with Applications or Applets when using Microsoft Internet Explorer IE3, IE4 and Netscape Communicator (Communicator must have Java 1.1 upgrade).

The Java class files included with the demo

Is a scaled down version of the serial port interface class.

Is a scaled down version of the serial port configuration interface class.

Is a simple console terminal application allowing you to send keystrokes to the serial port and reporting bytes received from the serial port.

Is a scaled down version of the file that comes with the SerialPort product. The demo version only allows selection of the port number.

This is the thread that receives characters from the port and displays them in the receive box.

The Native Shared Libraries (DLL's)

These files are contained in the file

WindowsNT x86


Linux x86
FreeBSD x86
Solaris x86
Solaris Sparc



Using The Demo

We assume you are familiar with using the JDK and that you have one of the following installed: Café, Visual Café, Metrowerks Java, JDK1.0.2, JDK1.1.x, MS-JDK 1.0, 1.5, 1.51, or 2.0PR2. Any Java Virtual Machine (JVM) compliant with Sun's Java Native Interface (JNI) or Microsofts Raw Native Interface (RNI) should also work. Borlands JBuilder is an example of an application that is JNI compliant.

The demo class files are in These were compiled with the JDK 1.1.3. Note that the SerialPort classes will work on either Java 1.0.2 or Java 1.1, however the demo uses the AWT, and the new event delegation model used by the AWT in Java1.1 is not 100% compatible with 1.0.2. We have provided a set of classes especially for use with the JDK1.0.2 if you are using an older VM. These classes can be found in the file

To run the demo with Café, Visual Café, or a Sun JDK, enter the command  java JavaTermDemo comName for example to use with COM3 enter  java JavaTermDemo COM3.

To run the demo with J++ or a MS-JDK enter the command jview JavaTermDemocomName

To run the demo with JDK 1.0.2 use only the COM number, e.g.  java JavaTermDemo 3

Note: Microsoft's jview does not correctly report an unsatisfied link error if it cannot find a DLL. If you start JavaTermDemo and you do not see the JavaTerm GUI window the most likely cause is the MS JVM cannot find the DLL(s). There is also an apparent bug with MS JDK 1.0 where it requires the entry DLL to be in the current directory. If you have MS JDK1.0 the best way to run this demo is to put all the DLLs in the current directory.

For OS/2 use the command javapm JavaTermDemo devName, or java JavaTermDemo devName.

When the java JavaTermDemo form of the command is used, output from System.out will show up in the original command line window. If a specific Java console is desired, set the environment variable JAVA_CONSOLE=1 before running javapm.

If you want to use the "Run Java Program" or "Run Java PM Program" icons in the "Java for OS/2" folder, there are two requirements. First place the required class files in a directory specified by CLASSPATH, then place the DLLs in a directory (other than ".") specified by LIBPATH. Following these configurations, when the icon is double clicked, it will prompt for a parameter which should be entered as JavaTermDemo.

IBM JDK 1.1.4 bug
The IBM JDK 1.1.4 has a bug that causes the VM to report it is running on Window 95 even when running on OS/2. This version of the VM will not work with the SerialPort demo.

To run the demo with the Metrowerks VM, double-click on the file

Linux x86
FreeBSD x86
Solaris x86
Solaris Sparc
SGI Irix Mips

To run the demo with the Sun JDK, enter the command  java JavaTermDemo devName where devName is the name of the serial device e.g. /dev/ttyR0.

SGI Irix Mips Note

To run the demo with some versions of IRIX and the SGI JDK , you may need to involke the MIPS ABI options. For example with SGI JDK 1.1.6 on IRIX 6.4 use the MIPS o32 ABI by entering the command  java -32 JavaTermDemo devName where devName is the name of the serial device e.g. /dev/ttyd2/.

Demo Restrictions.

The 'real' product does not have these restrictions

 If the device entered on the command line is in use select an alternate port by selecting Port | Settings from the menu. Use the demo to send send characters to the serial port by typing in the upper window, all characters received will be shown in the lower window. Non-printable characters (except newline: value 10) will be displayed with their Java byte value like this <value>. Note: Windows does not always detect serial ports in use by certain drivers (mouse, trackball, tablet, etc). If you find your mouse stops working run the demo and pass the desired port number as a command line argument. For COM3 you would do this java JavaTermDemo COM3

Building Applets

If you are planning to build applets with SerialPort, our Termlet package can be purchased to aid your development. The Termlet package includes step-by-step instructions on how Termlet was created, the source code for Termlet, supporting build files, and other useful information related to running applets that access the serial ports on the browsers machine. Contact sales@sc-systems for details.

Get your Java serial port project moving ahead full steam...purchase SerialPort today!

Contact US
If you have questions or comments please contact us.
Solutions Consulting,
Santa Barbara, CA