Can't locate serial ports

D

Daniel Hoag

I've downloaded the Java Comm 2.0 API and followed the instructions
for installation. I can compile and initially run their demo
programs, but apparently the CommPortIdentifier.listPortIdentifiers()
method returns nothing, so I can't recognize or connect to any ports.

I'm using jdk 1.4.2 on WinXP. I've triple checked that the
javax.comm.properties file is in the JAVA/lib/ directory, but it still
can't locate my ports.

I'd be greatful for any ideas on what could be going on.

Thanks,
Daniel
 
K

Knute Johnson

Daniel said:
I've downloaded the Java Comm 2.0 API and followed the instructions
for installation. I can compile and initially run their demo
programs, but apparently the CommPortIdentifier.listPortIdentifiers()
method returns nothing, so I can't recognize or connect to any ports.

I'm using jdk 1.4.2 on WinXP. I've triple checked that the
javax.comm.properties file is in the JAVA/lib/ directory, but it still
can't locate my ports.

I'd be greatful for any ideas on what could be going on.

Thanks,
Daniel

To compile or run the comm.jar must be in the CLASSPATH. To compile,
the javax.comm.properties must be in the jdk lib directory. To run, the
javax.comm.properties must be in the jre lib directory and the
win32com.dll must bin in the jre bin directory.

This also varies by sdk version too. But this should work with every
sdk from 1.3 to 1.5.

Try the short program below to check for ports. Unfortunately I have
found that sometimes you cannot get to the serial ports. I have a Dell
laptop that I cannot access the serial ports on.

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

public class Ports {
public Ports() {
CommPortIdentifier cpi = null;

Enumeration e = CommPortIdentifier.getPortIdentifiers();

while (e.hasMoreElements()) {
try {
cpi = (CommPortIdentifier) e.nextElement();
} catch (NoSuchElementException n) {}
System.out.println(cpi.getName());
}
}
public static void main(String[] args) { new Ports(); }
}
 
D

Dale King

Daniel Hoag said:
I've downloaded the Java Comm 2.0 API and followed the instructions
for installation. I can compile and initially run their demo
programs, but apparently the CommPortIdentifier.listPortIdentifiers()
method returns nothing, so I can't recognize or connect to any ports.

I'm using jdk 1.4.2 on WinXP. I've triple checked that the
javax.comm.properties file is in the JAVA/lib/ directory, but it still
can't locate my ports.

I'd be greatful for any ideas on what could be going on.


What is often a problem is that when you install the SDK there are actually
two JRE's installed. One is the public one in Program Files the other is in
the SDK directory. You have to install it in the one you are using. I
usually just install it in both places.
 
D

Daniel Hoag

Thank you so much, installing the Comm API files to the Program
Files\Java\<JRE> directory did the trick perfectly.

Thank you!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top