# Java Communications API for Linux platforms

# User Guide

# Copyright information

Note: Before using this information and the product it supports, be sure to read the general information under Notices.

This edition of the User Guide applies to the Java Communications API for Linux, and to all subsequent releases and modifications until otherwise indicated in new editions.

(c) Copyright Sun Microsystems, Inc. 1997, 2003, 901 San Antonio Rd., Palo Alto, CA 94303 USA. All rights reserved.

(c) Copyright International Business Machines Corporation, 1999, 2005. All rights reserved.

U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

# Contents

Copyright information
Overview
Location of Java Communications API files
Configuring Java Communications API
| |
Changing the access mode of serial and parallel ports
| |
Specifying devices in the javax.comm.properties file
Setting the PATH
Redistribution requirements
Uninstalling Java Communications API
Uninstalling the installable Red Hat Package Manager (RPM) package
Uninstalling the compressed Tape Archive (TAR) package
| |
Enabling serial ports on IBM ThinkPads
Documentation
| |
Known limitations
Notices
Trademarks

# Overview

Java(TM) Communications application programming interface (API) gives Java applications a platform-independent way of performing serial and parallel port communications for technologies such as voice mail, fax, and smartcards. After writing serial or parallel port communications for your application, you can then include those files with your application. Use Java Communications API if you want to write Java programs that access serial or parallel ports.

The Java Communications API supports Electronic Industries Association (EIA)-232 (RS232) serial ports and Institute of Electrical and Electronics Engineers (IEEE) 1284 parallel ports and is supported on systems with the IBM(R) Runtime Environment for Linux platforms, Java(TM) 2 Technology Edition, Version 1.4.2.

Technical changes made to this User Guide for Version 1.4.2, other than minor or obvious ones such as updating "1.4.1" to "1.4.2", are indicated in red when viewing in HTML or in a color-printed copy and by vertical bars to the left of the changes.

For the list of distributions against which the SDK for Linux has been tested, see:
http://www-106.ibm.com/developerworks/java/jdk/linux/tested.html

Using Java Communications API, you can:

- List ports on a system
- Open and claim ownership of ports
- Resolve port ownership contention among applications that use Java Communications API
- Perform asynchronous and synchronous I/O port-monitoring through event notification
- Receive bean-style events describing state changes on the port

# Location of Java Communications API files

The Java Communications API files are installed as shown:

- jre/lib/ext/comm.jar
- jre/bin/libibmcomm.so
- jre/lib/javax.comm.properties

For example, if you accepted the default directory when you installed the Red Hat Package Manager (RPM) package, the comm.jar file is in the /opt/IBMJava2-142/jre/lib/ext directory.

If you installed the package in another directory, the files are in the same directory structure, but /opt/IBMJava2-142/ is replaced by the directory where you installed Java Communications API .

# Configuring Java Communications API

After you install Java Communications API, you must:

- Change the access mode of serial and parallel ports
- Set the PATH

| | |

## Changing the access mode of serial and parallel ports

|

After you install Java Communications API, you must change the access mode |of serial and parallel ports so that users can access these devices. You must |give a user read/write access to the required devices. Log on as root and |use the following commands, as applicable:

|

        chmod 666 /dev/ttyS0    (AKA serial port COM1)
    |    chmod 666 /dev/lp0      (AKA parallel port LPT1)
    |    chmod 666 /dev/ttyS1    (AKA serial port COM2)
    |    chmod 666 /dev/ttyS2    (AKA serial port COM3)
    |    chmod 666 /dev/ttyS3    (AKA serial port COM4)

|

These commands give read/write access to everyone on the system.

|

An alternative method is to make the permissions 660 and add specific users |to the group in which the devices reside. On a SUSE system, for example, the |devices are in the `uucp` group. Thus, users can |be added to the `uucp` group to gain access to the |devices.

|

Change the access mode of any other ports as needed.

| |

### Specifying devices in the javax.comm.properties file

|

The file javax.comm.properties allows you to specify the prefixes of the |devices that are made available to the Java Communications API and whether |they are parallel or serial. Port numbers are allocated sequentially to all |devices. For example, if you specify `/dev/ttyS=PORT_SERIAL` and |the devices `/dev/ttyS0` and `/dev/ttyS1` exist, they will |be allocated COM1 and COM2 respectively.

|

|To use the USB-serial connectors, uncomment |the line `/dev/ttyUSB=PORT_SERIAL` in the javax.comm.properties file|. If the devices `/dev/ttyUSB0` and `/dev/ttyUSB1` exist |and COM1 and COM2 have already been defined, the USB-serial devices are allocated |the next sequential ports, COM3 and COM4.

## Setting the PATH

After you install Java Communications API, you must set the PATH:

    export PATH=/opt/IBMJava2-142/jre/bin:$PATH

# Redistribution requirements

If you plan to redistribute Java Communications API with the IBM SDK and your product, you must package the files listed in Location of Java Communications API files.The files must be included as part of your product installation and placed in the appropriate subdirectories on the user's system.

# Uninstalling Java Communications API

The process you use to uninstall the Java Communications API depends on whether you installed the installable Red Hat Package Manager (RPM) package or the compressed Tape Archive (TAR) package. See Uninstalling the installable Red Hat Package Manager (RPM) package or Uninstalling the compressed Tape Archive (TAR) package for instructions.

## Uninstalling the installable Red Hat Package Manager (RPM) package

To uninstall the Java Communications API if you installed the installable RPM package:

1. At a shell script, type:

           rpm -e <packagename>

   Alternatively a graphical tool such as kpackage or yast2 may be used.

2. If the directory where you installed the Java Communications API does not contain any other tools that you require, remove that directory from your PATH statement.

## Uninstalling the compressed Tape Archive (TAR) package

To uninstall the Java Communications API, if you installed the compressed TAR package, delete the following files from the directory where you installed them:

- jre/lib/ext/comm.jar
- jre/lib/libibmcomm.so
- jre/lib/javax.comm.properties

| | |

# Enabling serial ports on IBM ThinkPads

|

Most ThinkPads have their serial ports disabled by default in the BIOS. |Currently, there is no way to enable the ports with Linux (the tpctl package does not enable the ports if they are disabled in the |BIOS).

|

To enable the ports on Linux, your machine must have dual boot with Windows |installed on one of the partitions.

|

To enable the ports in the BIOS, you must use the DOS version of the ThinkPad |Configuration Utility that is available from the IBM ThinkPad Download site. |To use the ThinkPad Configuration Utility you will need a bootable DOS diskette. |Note that the ThinkPad Configuration Utility might have been installed as |part of the ThinkPad Utilities under Windows, depending on the options you |chose during installation, and you can run it from a command prompt in Windows.

|

The ThinkPad Configuration application provided with Windows has options |to enable or disable the serial and parallel ports but this does not also change the settings in the BIOS. So if you use this application |with Windows, the ports are available; however, if you reboot your machine |with Linux, the ports will not be enabled.

# Documentation

You can find API documentation and samples for Java Communications API at the Sun Web site:

http://java.sun.com

| | |

# Known limitations

|

Note the following known limitations:

|

|
- When printing with the Java Communications API, you might have to press |the button labeled "Form feed" or "Continue" or similar on the printer. |
|
|
- |The Java Communications API cannot support parallel port |operations on the SLES 9 GA and SP1 kernels. This limitation is resolved in |the SP2 kernel. The SuSE Bugzilla number is 50028. |
  |
|
|
- |Because of an unimplemented IOCTL function in the 32-bit |mode of the 64-bit kernel, the Java Communications API cannot support serial |port operations on SLES 9 and RHEL 4. This limitation is resolved in SLES |9 SP2 (Bugzilla number 49787) and RHEL 4 update 1 (Bugzilla number 144904). |
  |

# Notices

This information was developed for products and services offered in the U.S.A. IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service.

IBM may have patents or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents. You can send license inquiries, in writing, to:

- IBM Director of Licensing
  IBM Corporation
  North Castle Drive, Armonk
  NY 10504-1758 U.S.A.

For license inquiries regarding double-byte (DBCS) information, contact the IBM Intellectual Property Department in your country or send inquiries, in writing, to:

- IBM World Trade Asia Corporation Licensing
  2-31 Roppongi 3-chome, Minato-ku
  Tokyo 106-0032, Japan

The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law:

INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you.

This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the information. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this information at any time without notice.

Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk.

IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you.

Licensees of this program who wish to have information about it for the purpose of enabling (i) the exchange of information between independently created programs and other programs (including this one) and (ii) the mutual use of the information which has been exchanged, should contact:

- JIMMAIL@uk.ibm.com
  [Hursley Java Technology Center (JTC) contact]

Such information may be available, subject to appropriate terms and conditions, including in some cases, payment of a fee.

The licensed program described in this document and all licensed material available for it are provided by IBM under terms of the IBM Customer Agreement, IBM International Program License Agreement or any equivalent agreement between us.

Any performance data contained herein was determined in a controlled environment. Therefore, the results obtained in other operating environments may vary significantly. Some measurements may have been made on development-level systems and there is no guarantee that these measurements will be the same on generally available systems. Furthermore, some measurement may have been estimated through extrapolation. Actual results may vary. Users of this document should verify the applicable data for their specific environment.

Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.

## Trademarks

IBM, iSeries, pSeries, and zSeries are trademarks or registered trademarks of International Business Machines Corporation in the United States, or other countries, or both.

Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.

Other company, product, or service names may be trademarks or service marks of others.