Solved

No output from Port Query using javax.comm

Posted on 2006-07-05
3
224 Views
Last Modified: 2010-03-31
I've installed javax.comm package (version 2.0) under Win XP.
I compile and run the following code but don't get any output.
Can anyone tell me why?

Cheers,
Steve

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

public class PortList
{
  public static void main(String [] args)
  {
       Enumeration portList = CommPortIdentifier.getPortIdentifiers();

          while(portList.hasMoreElements()) {
        CommPortIdentifier portId = (CommPortIdentifier)portList.nextElement();
      if( portId.getPortType() ==
                  CommPortIdentifier.PORT_SERIAL)
        {
          System.out.println("Serial port: " +
                                   portId.getName());
         } else if (portId.getPortType() ==
                     CommPortIdentifier.PORT_PARALLEL)
           {
            System.out.println("Parallel port: " +
                                     portId.getName());
           } else
             System.out.println("Other port: " +
                                      portId.getName());
          }
    }
}
0
Comment
Question by:stevebeech
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 250 total points
ID: 17042277
Have you registered the comm package and installed the configuration files properly? Have a look here: http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21906501.html
0
 

Author Comment

by:stevebeech
ID: 17042316
Thanks Girionis!

I'd registered the commpackage correctly with the JDK, but hadn't copied the .dll and .props file into the JRE folders. It really ought to mention this in the installation instructions for the comm package.

Thanks for your (ever-so-quick) response.

Steve
0
 
LVL 35

Expert Comment

by:girionis
ID: 17042367
Thank you for accepting, glad I was of help :)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now