Re: Serial Port problem

From: nik[no-spam]cross (_at_wet-wired.com)
Date: 09/03/04


Date: Fri, 03 Sep 2004 10:36:39 +0100


<- Chameleon -> wrote:

>>>Enumeration portList = CommPortIdentifier.getPortIdentifiers();
>>>
>>>this command returns an empty Enumeration. Why?
>>>
>>>My system is PC with WinXP.
>>>I have 1 parallel and 2 serial ports
>>>
>>>
>>
>>As a first thought, have you initialized the comm driver.
>>I forgot and couldn't see any ports until I used this:
>>
>> String driverName = "com.sun.comm.Win32Driver";
>> try{
>> CommDriver commdriver =
>>(CommDriver)Class.forName(driverName).newInstance();
>> commdriver.initialize();
>> }
>> catch (Exception e2)
>> {
>> e2.printStackTrace();
>> }
>>
>>If this doesn't help maybe you could post your code.
>
>
> I have javax.comm.properties file inside <java dir>\lib directory and this
> file have this line inside:
> -------------
> Driver=com.sun.comm.Win32Driver
> -------------
> Your code works and thankyou, but why I must load dynamically this driver?
> If I want to run this code in Linux or other platform?
>
> Thanks again!
>
>
If that works my first thought would be that you do not have your java
lib path set up correctly. What environment/IDE are you developing in?
Do you have multiple JREs installed and if so have you installed the
Java comm api in the one ypu are running?