This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting available ports using Javax.comm  RSS feed

umar hathab
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I was trying to get the available port using the following sample program.But I couldnt get any output.
can u help me?

import java.util.*;
import javax.comm.*;
public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static String messageString = "Hello, world!\n";
static SerialPort serialPort;
static OutputStream outputStream;
public static void main(String[] args) throws NoSuchPortException

portList = CommPortIdentifier.getPortIdentifiers();

while (portList.hasMoreElements())
portId = (CommPortIdentifier) portList.nextElement();

if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
// if (portId.getName().equals("COM1")) {
if (portId.getName().equals("/dev/term/a"))
try {
serialPort = (SerialPort)"SimpleWriteApp", 2000);
} catch (PortInUseException e) {}
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}
try {
} catch (UnsupportedCommOperationException e) {}
try {
} catch (IOException e) {}

I am getting the following error.(It tells there is no elements in the Enumeration)
Error loading win32com: java.lang.UnsatisfiedLinkError: no win32com in java.library.path
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!