Comm api 2.0 - CommPortIdentifier.getPortIdentifiers() returns empty enum

Hi,
I'm trying to open connetion with my GSM modem which it connected to my PC by RS-232 cable.
I'm trying to run my program on Windows XP.
But, when i'm running the following piece of code, the enumeration return empty.
How it can be solved?
Enumeration en = CommPortIdentifier.getPortIdentifiers();
System.out.println(en);
// Iterate through the ports.
while (en.hasMoreElements()) {
portId = (CommPortIdentifier) en.nextElement();
if(portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
System.out.println(portId.getName());
On the Widows, Device manager, i can find the modem under Ports section/
Thanks,
Eyal.

eyalm_nm wrote:
But, when i'm running the following piece of code, the enumeration return empty.Welcome to the Sun Forums,
First of all, Enumerations and enums are completely different things. Don't use those terms interchangeably. Second, when posting code please highlight it in the editor and click the CODE button.
Is the Enumeration empty, or does it not contain an element where getPortType() == CommPortIdentifier.PORT_SERIAL?

Similar Messages

  • CommPortIdentifier.getPortIdentifiers() returns nothing on linux

    Sorry for bad english, please.
    I does theese steps:
    1. Read manual about installing java comm
    2. Download java comm for Windows and for Linux
    3. Exec installation steps (comm.jar into %JAVA_HOME%/lib/ext, native libs into %JAVA_HOME%/lib/<platform named dir>, javax.comm.properties with correct driver name into %JAVA_HOME%/lib).
    4. Run demo app "BlackBox" on Windows. All ok. Port found, works correctly.
    5. Run demo on Linux. It writes "No com ports found".
    I cannot understand, why. Can someone help me?
    PS external lib RXTX causes same result - "No com ports found".
    However, it is fact, that com ports phisycally exists.
    After I write my app, I found, that method CommPortIdentifier.getPortIdentifiers() returns empty values list on linux. Can any tell, why?

    eyalm_nm wrote:
    But, when i'm running the following piece of code, the enumeration return empty.Welcome to the Sun Forums,
    First of all, Enumerations and enums are completely different things. Don't use those terms interchangeably. Second, when posting code please highlight it in the editor and click the CODE button.
    Is the Enumeration empty, or does it not contain an element where getPortType() == CommPortIdentifier.PORT_SERIAL?

  • Comm API problems (getPortIdentifier)

    Hi! I wrote an applet that uses the javax.comm API to manage a serial port in the host machine. When first develop it with JDK 1.1.8 the applet (and an application) runs perfectly. I now have Java 2 (jdk1.3.1._02) and I'm trying to run this applet and when it arrives to a CommPortIdentifier.getPortIdentifier(String) call, I got this message:
    "java.io.lang: name can't be null"
    First I thought that was my applet, that my application was wrong, so I try to use de SerialDemo example that comes with the javax.comm and It doesn't work either! If I run it with the latest beta version of JDK (1.4 I think) it runs again... any idea???
    Thanks a lot! =)

    in jdk1.3...
    u have to copy the win32com.dll and comm.properties file in the jre\1.3\bin folder of the machine
    and comm.jar in the jre\1.3\lib folder....
    remember, in windows, u will get the
    ...\program files\javasoft\jre\1.3\lib or ..\bin
    ther u have to store not in ur c:\jdk1.3\bin
    Regards,
    Ritesh

  • Bug in CommPortIdentifier.getPortIdentifiers()

    Hi,
    CommPortIdentifier.getPortIdentifiers()
    From java communications API, when called again returns resultset twice. After each successive invokation it keeps adding the ports to the last result set.
    Here is the test code:
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    Every call to listPorts keep adding machine port list to the last result set.
    Any idea what's going on? Is this a bug?
    I am trying the same logic in an Applet. Even if I call listPorts from applet init method, it still has the same problem.import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    import javax.comm.*;
    import java.util.Enumeration;
    public class Test {
         public static String listPorts() {
              System.out.println("listPorts Called");
              String drivername = "com.sun.comm.Win32Driver";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              drivername = "javax.comm.*";
              try
                   CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
              catch (Throwable th)
              // Discard it
              StringBuffer portList = new StringBuffer("");
              Enumeration ports =
              CommPortIdentifier.getPortIdentifiers();
              int portCount = 0;
              while (ports.hasMoreElements()) {
              portCount++;
              CommPortIdentifier port =
                   (CommPortIdentifier)ports.nextElement();
              String type;
              switch (port.getPortType()) {
                   case CommPortIdentifier.PORT_PARALLEL:
                   type = "Parallel";
                   break;
                   case CommPortIdentifier.PORT_SERIAL:
                   type = "Serial";
                   break;
                   default: /// Shouldn't happen
                   type = "Unknown";
                   break;
              // System.out.println(port.getName() + ": " + type);
              portList.append(port.getName() + ": " + type + " ");
              System.out.println("portCount="+portCount);
              System.out.println(portList.toString());
              return portList.toString();
         public static void main(String[] args) {
              listPorts();
              listPorts();
              listPorts();
              listPorts();
    The program prints ports for the first call and then keeps adding the ports to the result set for each successive call to listPorts from main.
    I am trying to run this from an applet. If I put the same code inside applet init method. I get the same behavior between page loads. Looks like it's per JVM invocation.
    Any help is appreciated.
    Thanks,
    Prashant Rane

    Each call to initialise will add its ports to the commportidentifier. This is how its supposed to work, as each driver is only supposed to be initialized once.
    Why don't you follow the examples on the javax.comm pages?
    http://java.sun.com/products/javacomm/javadocs/API_users_guide.html

  • COMM API problem

    Hello there
    I am hoping you can help me with following. I am trying to transfer files from one computer
    to another using a serial port and hence I am using the communications api. I have gotten so
    many errors on the problem. I have followed the information for installing the api but I
    still get errors. It will let me compile a file but when I try to run it it give me the
    following error
    NoClassDeffounder found
    What my lecturer did was opened up the jar file and put them into a separate folder. We then
    put them into the bin directory in the jdk.
    Everywhere in the code where it was calling a class,constant belong to the api we did the
    following
    comm.CommPortIdentifier.getPortIdentifiers();
    In the above line comm is the folder with the class files
    When we try to tun it now it executes.But it still cannot find any ports whatsoever
    Please can anyone at all help. I am stuck on this problem for over a month and is slowing me down
    Thanks

    No the code has not come from my tutor
    I've had 2 experts trying to help me and they dont
    know what the problem is
    I have tried the SerialDemo
    I still get the same result
    Any other ideasIf you have followed these instructions to the letter, which I doubt, then you probably need to re-install Windows.
    If they haven't fixed this relatively simple problem they are not experts. Consultants perhaps, but not experts.

  • COMM api ParallelPort locks

    Hello all,
    I'm trying to use the Parallel Port from COMM api just to send 1 byte to Paralell data I/O using the code below,
    portList = CommPortIdentifier.getPortIdentifiers();
    while (portList.hasMoreElements()) {
    portId = (CommPortIdentifier) portList.nextElement();
    portId.getPortType());
    if (portId.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
    try {
    parallelPort = (ParallelPort) portId.open("MoodMusic", 2000);
    } catch (PortInUseException e) { }
    // Writing to port
    try {
    outputStream = parallelPort.getOutputStream();
    outputStream.write("Hello World".getBytes());
    } catch (Exception e) { System.out.println(e.getMesssage());}
    And the application keep locked when I proceed the write method,
    I do not need read anything from Parallel Port and I have no device connected it.
    Is it possible to use the ParalelPort class just to send bytes , It is needed something else to work? or It just work for printers.
    best regards,

    Thank you very much Jos,You're welcome.
    But I really do not understand the solution you proposed, I really need
    an answer from device or Could I solve it from PC Host?Sun's API expects that nAck negative pulse; if it doesn't arrive it won't
    send new data. You either need to fake that pulse (using a bit of
    additional hardware triggered by the strobe signal coming from the host)
    or maybe (just a quick idea), you could set a small timeout value and
    try to send your bytes one by one. This would slow down the communication
    speed substantially but you don't need to build special hardware.
    If your device is fast enough it would pick up the eight bits of data and
    then Sun's API would time out. This way you also lose quite a lot of
    functionality like error detection etc.
    kind regards,
    Jos

  • Help...problems using java comm API

    Hi all
    im using Fedora Core and in order to list all the available serial ports for my computer i'm using the classic program TestEnumeration, but when running from jbuilder 2005 not from shell i received the following errors:
    Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
    Caught java.lang.UnsatisfiedLinkError: readRegistrySerial while loading driver com.sun.comm.SolarisDriver
    Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
    Caught java.lang.UnsatisfiedLinkError: readRegistrySerial while loading driver com.sun.comm.SolarisDriver
    warning: no ports found - make sure javax.comm.properties file is found
    i have followed all the instruction to install comm API but i received the same error i need help plz if someone can
    thx

    import java.io.*;
    import java.util.*;
    import javax.comm.*;
    import java.lang.*;
    import java.Buff.*;
    public class SimpleRead implements Runnable, SerialPortEventListener
         static CommPortIdentifier portId;
         static Enumeration portList;
         InputStream inputStream;
         SerialPort serialPort;
         Thread readThread;
         public static void main(String[] args)
         {//System.out.println("hello");
              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")) {
              SimpleRead reader = new SimpleRead();
         public SimpleRead()
         try
              serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
         catch (PortInUseException e)
                                  System.out.println(e);
         try
         inputStream = serialPort.getInputStream();
         catch (IOException e)
                        System.out.println(e);
                   try
    serialPort.addEventListener(this);
                   catch (TooManyListenersException e)
                        System.out.println(e);
         serialPort.notifyOnDataAvailable(true);
         try
         serialPort.setSerialPortParams(9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
              catch (UnsupportedCommOperationException e)
                        System.out.println(e);
    try {
    out = new OutputStreamWriter(serialPort.getOutputStream());
    out.write("ATQ0V1E0");
    out.flush();
    out.write("ATQ0V1E0");
    Out.close();
    //System.out.println("ATQ0V1E0");
    catch (IOException e) {}
    try {
    int line;
    int result ;
    InputStream = serialPort.getInputStream();
    int num= inputStream.available();
    InputStreamReader reader = new InputStreamReader(inputStream);
    System.out.println(reader.ready());
    while ((line = reader.read()) <= 0)
    result =reader.read();
    System.out.println("Success " + result);
    reader.close();
    catch (IOException e) {}
    readThread = new Thread(this);
    readThread.start();
    try {
    OutputStream = SerialPort.getOutputStream();
    catch (IOException e) {}
              System.out.println("ATQ0V1E0");
    public void run()
         try
    Thread.sleep(500);
    catch (InterruptedException e)
                   System.out.println(e);
    public void serialEvent(SerialPortEvent event)
    switch(event.getEventType())
    case SerialPortEvent.BI:
    case SerialPortEvent.OE:
    case SerialPortEvent.FE:
    case SerialPortEvent.PE:
    case SerialPortEvent.CD:
    case SerialPortEvent.CTS:
    case SerialPortEvent.DSR:
    case SerialPortEvent.RI:
    case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
    break;
    case SerialPortEvent.DATA_AVAILABLE:
    byte[] readBuffer = new byte[20];
    try
    while (inputStream.available() > 0)
    int numBytes = inputStream.read(readBuffer);
    System.out.print(new String(readBuffer));
    catch (IOException e)
                        System.out.println(e);
    break;
    hi friends am getting these errors
    C:\programs>javac SimpleRead.java
    SimpleRead.java:115: illegal start of expression
    public void run()
    ^
    SimpleRead.java:159: ';' expected
    ^
    2 errors
    please help me....
    its very urgent....this is the first program of mine.... am so tensed..
    i should finish this soon... please help me...
    this is my mail ID
    [email protected]

  • Is IRDA Works On Comm Api

    I Have connected IRDA in USB and Create a virtual modem com4.My work is to send message between mobile through PC and vice versa.First We work on serial cable connected with my PC and Nokia6610.But
    I face lot of Problem with AT command so I wanna be work with IRDA because All AT command work fine.
    I test it in Hyperterminal.But We will be implemented it only one way and that is comm api.But Comm api works on Serial and Parallal Port.But I create Virtual port com4.Can i do it in comm api with IRDA connection?
    I Want to know Only One Thing----------------
    Can i work IRDA with my comm API?
    (Though It is not connected with the serial port but create a virtual port com4)
    PLS & PLS Help Me Only This ANS.

    yes iRDA works, I tested some of the AT+ Commands on iRDA Nokia 7110 via my laptop hope my answer does work.
    //Virtual Comm Port .. COM4
    CommPortIdentifier portID = CommPortIdentifier.getPortIdentifier("COM4");

  • My last chance...for comm api with applet

    Hi to u great valued developers,
    Did anybody on earth the same as I do:
    Create and deploy a signed applet including the java comm api lib.
    The applet is deployed on an Apache Server and should run under IE6
    Easy? sure but something is certainly missing in the cab 'cause altough no error is return in console, I either do not receive any info from the ports.
    Same app compiled as application is ok.
    Thanks very much for any help.
    Cedric ([email protected])

    Hello Enrique,
    tx for ur answer.
    As said, the application (reading serial ports) works fine.
    The problem come possibly from javax.comm.property.
    Should I package it with the cab?

  • Including a DLL in JAR file (Comm API)

    Writing a little app that interfaces with serial port device using the communications API and I'd like to bundle it into an executable JAR. JBuilder will create the JAR for me fine, but the issue is with the win32com.dll file thats part of the comms API. I need to include this, I don't think its possible to include as part of the executable, but otherwise the DLL needs to be in the windows\system folder. Could I include the dll as part of the JAR archive and then extract it upon runtime? If so how would I go about this?
    Any help much appreciated.

    There is another option. Native libraries need to reside within the java.library.path location. As it turns out, if you, at runtime, grab this property and ADD your own location to it, then set it back in to the System.setProperty() call, it will NOT work. The only way to do it is the -Djava.library.path value that tjmaven suggested.
    However, if you read up on how a native library is found, it uses the ClassLoader.loadLibrary() which calls the protected findLibrary() method. You can therefore extend ClassLoader to find a path yourself.
    One way is to extend URLClassLoader since it has the protection/security stuff AND the ability to look in .jar files for you. Your custom loader is created by a "launcher" class in your .jar file. First, your luancher uses getClass().getProtectionDomain().getCodeSource().getLocation() to get the absolute location of the .jar file its executing within. From there, you open the jar and look for your native library, extract it using the JAR api to a location of your choosing. Now, you instantiate the custom classloader and using this custom loader instance you load the rest of your classes. The main .jar file contains two classes, the launcher and the custom classloader, and contains the native library if you wish to do it this way. The custom classloader, you specify a URL[] of "classpath" entries. You bundle up the rest of your source in a second .jar file that you pass to the URL[] when creating the custom classloader. It will find all your classes in the 2nd jar no sweat. You can even "reload" these classes on the fly by recreating the custom classloader instance if you so wish to add a sort of "reload" feature.
    Now, in your custom classloader, you override the findLibrary() and return the SAME STRING PATH that you used to unjar your native files to. This way, when the JVM asks your custom loader to load the library at some path, you return the right path to find the native files in.
    I haven't verified that this works just yet, but I will soon. Primarily, my plugin engine over at www.platonos.org will support the ability to place native libraries in plugins, allowing you to effectively wrap a native library use as a plugin. Not yet working, but we'll soon have it in place.

  • Getting started in Java Comm API

    Hi This is all new to me. So I would really appreciate if anyone can help me figure this out..I am trying to read from the serial port using a VS4000 Image Scanner(Symbol). I want to scan a driver's license bar code. I believe PDF417 is the type of barcode to read driver's license. However, Im just curious if there is any code out there that actually parses the information out of the license. I need to get the lastname, firstname,dob,gender,address,drivers #, etc.. Does any one have any idea where I could get more information in how to scan a driver's license. I need more guidance in how to really do this. Although, I went to the introduction to Java Communications and found a example code "SimpleRead.java". However, I get some errors....
    can anyone help..I have a nullpointer ..not sure how to fix it...
    I get this error :
    java.lang.NullPointerException
         at SimpleRead.<init>(SimpleRead.java:64)
         at SimpleRead.main(SimpleRead.java:53)
    Exception in thread "main" Process terminated with exit code 1
    Here is the original code :
    import java.io.*;
    import java.util.*;
    import javax.comm.*;
    public class SimpleRead implements Runnable, SerialPortEventListener {
    static CommPortIdentifier portId;
    static Enumeration portList;
    InputStream inputStream;
    SerialPort serialPort;
    Thread readThread;
    public static void main(String[] args) {
    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")) {
    SimpleRead reader = new SimpleRead();
    public SimpleRead() {
    try {
    serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
    } catch (PortInUseException e) {}
    try {
    inputStream = serialPort.getInputStream();
    } catch (IOException e) {}
         try {
    serialPort.addEventListener(this);
         } catch (TooManyListenersException e) {}
    serialPort.notifyOnDataAvailable(true);
    try {
    serialPort.setSerialPortParams(9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e) {}
    readThread = new Thread(this);
    readThread.start();
    public void run() {
    try {
    Thread.sleep(20000);
    } catch (InterruptedException e) {}
    public void serialEvent(SerialPortEvent event) {
    switch(event.getEventType()) {
    case SerialPortEvent.BI:
    case SerialPortEvent.OE:
    case SerialPortEvent.FE:
    case SerialPortEvent.PE:
    case SerialPortEvent.CD:
    case SerialPortEvent.CTS:
    case SerialPortEvent.DSR:
    case SerialPortEvent.RI:
    case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
    break;
    case SerialPortEvent.DATA_AVAILABLE:
    byte[] readBuffer = new byte[20];
    try {
    while (inputStream.available() > 0) {
    int numBytes = inputStream.read(readBuffer);
    System.out.print(new String(readBuffer));
    } catch (IOException e) {}
    break;
    Thanks a bunch!! :)
    Jess...

    I actually got my scanner to work. I got my SimpleRead.java to work as an application. I set up this as an applet. Now my problem is that I the inputread reading from the serial port is not reading correct data always. It sometimes does scan correct data at times and other times it will not. So, I am not sure what is wrong. Does anyone have any clue why this could happen?

  • Error in the latest Java comm api for Linux

    installed latest Java comm api for Linux, tried test application for the Sun package:
    $ java SimpleRead
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at SimpleRead.main(SimpleRead.java:67)
    Caused by: java.lang.NullPointerException
    at javax.comm.CommPortIdentifier.findConfFile(CommPortIdentifier.java:199)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:117)
    ... 1 more
    What deis this message mean? How to make you serial port support work?

    and what does this error message mean??
    The package was installed accordingly to "Java(tm) Communications API Linux Installation Instructions":
    $ls /usr/lib/libLinuxSerialParallel.so
    /usr/lib/libLinuxSerialParallel.so
    $env|grep CLASS
    CLASSPATH=<..skipped..>:/opt/commapi/jar/comm.jar:/opt/commapi/jar/commtest.jar
    $ ls /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    /opt/jdk1.5.0_04/jre/lib/javax.comm.properties
    What else does it need?

  • Configure comm.api in tomcat

    hello friends,
    i want to configure comm.api in tomcat5.5. please help me
    Thanks in advance.
    javax.comm: Error loading javax.comm.properties!
    null
    java.io.IOException: javax.comm: platform driver class name = null
    (Check 'driver' property in javax.comm.properties)
    at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:244)
    at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
    at welcome.list(welcome.java:47)
    at welcome.doGet(welcome.java:21)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)

    If your operating system works it as a comm port you can readily run the BlackBox example that comes with the comm 2.0 API and see if it picks it up.

  • Using Comm API with Web Start

    I am trying to use Sun's Comm API with Web Start so I can access COM1 from my application.
    When the application starts, I receive an exception for the CommPortIdentifier. When I run this
    application as a standalone, it works fine. I have to assume that there is a problem with the
    deployment of the Comm API.
    I have include the win32com.dll in a jar file and defined it in the nativelib tag in the jnlp file.
    The comm.jar and the javax.comm.properties files are include in another jar. I am not sure
    what is the proper way to deploy these files and cannot find any documentation on this.
    Does anyone know the correct way to handle this?

    I have include the win32com.dll in a jar file and
    defined it in the nativelib tag in the jnlp file.
    The comm.jar and the javax.comm.properties files are
    include in another jar. I am not sure
    what is the proper way to deploy these files and
    cannot find any documentation on this.
    should like like this
    <resources>
    <j2se version="..." href="..."/>
    <jar href="application.jar"/>
    <jar href="comm.jar" />
    </resources>
    <resources os="Windows">
    <nativelib href="win32com.dll"/>
    </resources>
    Then in the code in application.jar, call
    System.loadLibrary("win32com");
    /Dietz

  • Comm API and Exception in SerialDemo

    I was able to compile the SerialDemo source into the application. However, when I run it, it throws an exception at line 560 of SerialDemo$ConfigurationPanel.listPortChoices
    This line deals with enumerating the available ports on a system. The exception is a NoClassDefFound (no such class) error. It is looking for javax.comm.CommPortIdentifier
    I have installed Comm API 2.0 according to the Win32 directions. I once had a prior installation working - at least listing what ports I actually had on the system - but even then the apps were unable to work with them at all.
    Anyone got ideas?

    i have this error when run SerialDemo:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/comm/CommPortIdentifier
    at SerialDemo$ConfigurationPanel.listPortChoices(SerialDemo.java:560)
    at SerialDemo$ConfigurationPanel.<init>(SerialDemo.java:448)
    at SerialDemo.<init>(SerialDemo.java:142)
    at SerialDemo.main(SerialDemo.java:89)
    My CLASSPATH :
    C:\j2me\midp2.0fcs\classes;C:\Benhui_Bluecove;
    C:\Benhui_Bluecove\classes;
    C:\WTK23\apps\BTGalleryExample\src;
    C:\Programmi\UCB\jdk1.4.1_02\j2sdk1.4.1_02\jre\lib\comm.jar;
    and i have followed the instructions that are at http://www.benhui.net
    These are the instructions :
    To get mine to work, I copied the 'comm.jar' and 'javax.comm.properties' files into the following locations:
    * <J2SE SDK installation directory>\lib
    * <J2SE SDK installation directory>\jre\lib
    * <J2SE SDK installation directory>\jre\lib\ext
    And copied the 'win32com.dll' into the following locations:
    * <J2SE SDK installation directory>\bin
    * <J2SE SDK installation directory>\jre\bin
    Can someone help me?
    Thanks
    Dani

Maybe you are looking for

  • G5 Dual 2.5 (June 2004) Power Mac LOCKS UP After 20 -30 Minutes

    Ever since the Apple 5.1.8f7 firmware update just before Christmas, my poor G5 Dual 2.5 will boot and run for about 20 to 30 minutes then lock up hard. No keyboard and no mouse activity. Have re-set the PRAM, swapped out the video card, swapped out t

  • Bridge is opening all of my RAW files as jpegs when I import them from iPhoto

    I have set my iPhoto preferences to send my RAW photos as RAW when using an external editor. If I only use ACR, this works fine, but if I want to use CS4 they are all coming over as jpegs and I then have to work w them as jpegs. I have PSE 8 . Do I h

  • Using jsf with struts

    hi; i am trying to understand the proper architecture when using jsf and struts together. i think i understand the differences between the technologies . it seems to me that instead of justifying jsf there should be a focus on how the two technologie

  • Limit purchase order

    Hi All, For my customer we are defining the Limit purchase order (new purchase order type) can any one help me in knowing the process flow for this. Limit purchase order will allow receipt to be made to value specified in the purchase order. Once the

  • Combo box + push button + knob

    Hi everyone, I am using LabVIEW 2009. I want to display drop down list of combo box upon clicking Push Button and navigate thro` the elements of drop down list of combo box by Knob. Please help me its urgent!!! Any suggestions are welcome. Regards, M