problem using seial port

J

jeroen

Hi,

For a project at school I need to read data from port COM2. I used som
examples from internet and created a project on it. Running the app it
looks like there is no COM port available.
This statment retuns null
System.out.println((CommPortIdentifier)portList.nextElement()); Tried
everything but something is missing.

selection of the code:
============================================
package talk2com;
import javax.comm.*;
import java.io.*;
import java.util.Enumeration;

public class Talk2Com {
//Construct the application
public Talk2Com(){
}

public static void main(String[] args) throws NoSuchPortException {
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
System.out.println((CommPortIdentifier)portList.nextElement());
}
===================================================================

Thanks Jeroen
(e-mail address removed)
 
D

Dale King

jeroen said:
Hi,

For a project at school I need to read data from port COM2. I used som
examples from internet and created a project on it. Running the app it
looks like there is no COM port available.
This statment retuns null
System.out.println((CommPortIdentifier)portList.nextElement()); Tried
everything but something is missing.

Usually the problem is that there are actually two runtimes installed when
you install Java. There is the one in the SDK for compiling and another
public one for running. The easiest way to handle this with JavaComm is to
simply install it into both places. So for example on Windows you might
install it in C:\j2sd1.4.2_03\jre and also in C:\Program
Files\Java\j2re1.4.2_03.
 

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,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top