One of the most popular interfaces on a PC is the serial port. This interface allows computers to perform input and output with peripheral devices. Serial interfaces exist for devices such as modems, printers, bar code scanners, smart card readers, PDA interfaces, and so on. Sun's JavaSoft division recently has made available the javax.comm package to add serial support to Java. This package provides support for serial and parallel devices using traditional Java semantics such as streams and events. In order to communicate with a serial device using a serial port on a host computer from a Java application or applet, an interface is required. This API allows you to transmit and receive data from external devices connected to your serial port. In addition, the API provides a complete set of options for setting all of the parameters associated with serial and parallel devices. This article focuses on how to use javax.comm to communicate with a serial device based on RS-232; discusses what the javax.comm API does and does not provide; and offers a small example program that shows you how to communicate to the serial port using this API. We will end with a brief discussion of how this API will work with other device drivers, and also go over the requirements for performing a native port of this API to a specific OS. (2,700 words)
One of the more interesting technologies to come out of Sun's Java Software Division recently has not had nearly the fanfare of Java3D, JFC, or even the 1.2 version of the JDK. I'm talking about the communications library: javax.comm. This article looks at the basic library features, and discusses my experiences implementing some code that uses a serial port in Java and on Windows 95. (3,000 words)