• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

portList.hasMoreElements() is getting false

 
Greenhorn
Posts: 9
Postgres Database Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following program to read and list the serial port,


I am using RXTX library for it.

I have compiled and run the java program as follows:

C:\SMS\work>javac Connectnow.java

C:\SMS\work>java Connectnow
portList=gnu.io.CommPortEnumerator@5e481248
false
I am getting the value of portList.hasMoreElements() as false. What to do? I have set all the things in the RXTX library correctly. I am using Windows 8.1 64bit system. Please help me. Why it is coming as false?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does your computer really have old-fashioned RS-232 serial ports? I doubt it if it's a modern machine (you say you are using 64-bit Windows 8.1). If it doesn't, then I'm not surprised that your program shows no serial ports.
 
Marshal
Posts: 75837
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I added code tags to your post: always use them. Doesn't it look better
Don't use Enumeration; it is legacy code which has been outdated for about 15 years. I see that the portList does not override the toString method, which is why you are getting that particular output.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

I added code tags to your post: always use them. Doesn't it look better
Don't use Enumeration; it is legacy code which has been outdated for about 15 years. I see that the portList does not override the toString method, which is why you are getting that particular output.



It's what the getPortIdentifiers method returns.
RxTx is getting on a bit, it has to be said...
 
Campbell Ritchie
Marshal
Posts: 75837
361
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably because nobody uses R232s any more.
 
reply
    Bookmark Topic Watch Topic
  • New Topic