CommPortIdentifier incorrectly lists available COM ports

J

John

I have some code (in an OSGi bundle) which uses a CommPortIdentifier
object to enumerate the available COM ports on a Windows XP system
(Dell Latitude laptop).
With portList being an Enumeration object, it sets:
portList = CommPortIdentifier.getPortIdentifiers();

When the code next calls 'portList.hasMoreElements(),' the method
returns 'false,' even though there clearly is a COM1 port which I can
observe in action using HyperTerminal (HyperTerm is closed when running
the Java code).

The strange thing is that this code has been known to work on this same
machine in the past. One day the behavior changed and I can't figure
out why...any suggestions would be greatly appreciated.
 
J

John

I should add that after reviewing posts on this topic, I found that the
file javax.comm.properties was in the c:\jre1.5.0_06\lib directory on
my desktop but absent on my laptop...this must be the problem, right?
I copied the file over, rebooted, and the problem persists.
Does anyone know whether I need to install the fullblown Java SDK
rather than just the skeleton JRE?
 
K

Knute Johnson

John said:
I should add that after reviewing posts on this topic, I found that the
file javax.comm.properties was in the c:\jre1.5.0_06\lib directory on
my desktop but absent on my laptop...this must be the problem, right?
I copied the file over, rebooted, and the problem persists.
Does anyone know whether I need to install the fullblown Java SDK
rather than just the skeleton JRE?

You don't need the JDK. There are three files, comm.jar which goes into
the JRE/lib/ext directory, javax.comm.properties which goes into the
JRE/lib directory and win32com.dll which goes into the JRE/bin
directory. Some operating systems report more ports than actually exist
but under reporting is usually an installation or coding problem.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top