473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Com ports not showing up using Java

158 100+
I'm running a small program that should list all of the comm ports that are available on the computer. The only problem is that nothing is recognized. I've stepped through the program and it jumps over the while .....hasMoreItems. When I set the hasMoreItems to false it executes it. There are no syntax errors and it runs completely, it just doesn't give me the info I need.

Thanks in advance!

Expand|Select|Wrap|Line Numbers
  1. package gps;
  2.  
  3. import javax.comm.*;
  4. import java.util.Enumeration;
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Enumeration port = CommPortIdentifier.getPortIdentifiers();
  9.         while (port.hasMoreElements()) {
  10.             CommPortIdentifier ports = (CommPortIdentifier) port.nextElement();
  11.             String type="";
  12.             switch (ports.getPortType()) {
  13.                 case CommPortIdentifier.PORT_PARALLEL:
  14.                     type = "Parallel";
  15.                     break;
  16.                 case CommPortIdentifier.PORT_SERIAL:
  17.                     type = "Serial";
  18.                     break;
  19.                 default: /// Shouldn't happen
  20.                     type = "Unknown";
  21.                     break;
  22.             }
  23.             System.out.println(ports.getName() + ": " + type);
  24.         }
  25.     }
  26. }
  27.  
Oct 11 '09 #1
1 2295
Jollywg
158 100+
Figured it out...this is happening because javax.comm is for solaris systems...Installed rxtxcomm and it works just fine.
Oct 12 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ina Schmitz | last post by:
hi newsgroup, I'd like to connect to a remote DB2 Database V 8.2 using the "DB2 Steuerzentrale" (I guess it's called something like "DB2 management console" in the English version). Since the...
3
by: andyI | last post by:
Where do I find information on how to address and pass data to and from the serial ports and USB ports in VB. VB6 supports the serial ports easily but I see no reference to using the USB ports....
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
3
by: Tom Brown | last post by:
Hey people, I've written a python app that r/w eight serial ports to control eight devices using eight threads. This all works very nicely in Linux. I even put a GUI on it using PyQt4. Still...
2
by: Mongkon | last post by:
I use Visual studio.net 2003 for develop a web application by communicate with Web service (it has been developed by Java) and I has added web reference but It can’t to and show error message...
2
by: joaquimfpinto | last post by:
Dear All, I made an app in c# that uses several serial ports. For the serial ports I use a pnp Sunix board, some with 8 serial ports other with 4 or even 2 serial ports. Whenever I use the...
10
by: sklett | last post by:
I'm trying to send some printer commands (ZPLII) to an attached USB printer using the SerialPort component. I didn't get very far at all. In fact I haven't gotten anywhere. The first problem I...
1
kirankumark
by: kirankumark | last post by:
hiii.. I am given a project work in my college..i.e. to operate an external device which captures images, for which i have to send the signals to the modem connected to the ports. so what...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.