Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-10-2003, 07:09 AM   #1
Registered: Mar 2002
Location: Ukraine, Kiev
Distribution: Mandrake 7.2
Posts: 37

Rep: Reputation: 15
Exclamation java comm api from ibm

Hello ALL!
I wrote a simple java program to test an ibm communication api implementation. But it throws IllegalMonitorStateException when I trying to close com port on RedHat Linux 7.3. Please comment this situation if you can.
This is a program:

import java.util.*;
import javax.comm.*;

public class Relay {

static final String comPortName = "COM1";
static final String toRealy = "BLABLABLA";

public static void main( String[] argv ) {
try {
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
CommPortIdentifier portId = getCommPortIdentifierByPortNumber( comPortName, portList );
SerialPort serialPort = (SerialPort) "Relay", 30000 ); // 30 secs timeout
// System.out.println( "Sleep before closing 1 sec." );
// Thread.sleep( 1000 );
// System.out.println( "About to close serial port." );
} catch( Throwable e ) {

protected static CommPortIdentifier getCommPortIdentifierByPortNumber( String strPort, Enumeration portList ) throws IllegalArgumentException {
while( portList.hasMoreElements() ) {
CommPortIdentifier cpi = (CommPortIdentifier) portList.nextElement();
if( cpi.getName().equalsIgnoreCase( strPort ) == true ) return cpi;
throw new IllegalArgumentException( "Invalid port: " + strPort );


This program throws following exception:
at java.lang.Object.notify(Native Method)
at Relay.main(

P.S.I found in an archive the same question but without answer
Old 02-10-2003, 10:50 PM   #2
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
I've never used IBM Comm API before but I've used the Comm API from the Sun website. It is not their API (they have no Comm API for Linux platform). They redirect a third party one. The link is located at the FAQ page of the "Sun website", "Comm API download page". I'm working fine with it.

Coming to your problem,

"COM1", "COM2" are the windows names for the comm ports.
On Linux,
"/dev/ttyS0" for COM1,
"/dev/ttyS1" for COM2 etc.

Try to use "/dev/ttyS0" rather than COM1 and see if it's Ok.

Last edited by moeminhtun; 02-11-2003 at 03:30 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
comm question webeye Programming 9 11-29-2005 01:49 AM
Comm 5 WillG SUSE / openSUSE 3 09-04-2005 11:16 PM
usb serial comm guyulmaz Mandriva 3 06-07-2005 02:20 AM
which should I use? diff cmp comm Frybyte Linux - Newbie 2 07-19-2004 09:22 AM
IBM Java, Netscape and Mandrake robertoneto123 Linux - Software 6 01-12-2004 02:37 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:43 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration