-   Programming (
-   -   Listening to Com ports in java (

MRMadhav 05-18-2006 12:39 AM

Listening to Com ports in java
Hi i would like to be able to retrieve data from the port com1 of my computer. A machine is connected to that port and it sends signals to the com1 port. When i use Hyper terminal in windows i am able to read the lines, is there a way to do this in java?

paulsm4 05-18-2006 12:47 AM

Hi -

If you're running Linux, you should be able to just open the appropriate device file ("/dev/ttyS0", for example), and use standard Java I/O.

Java also has a "Communications API":

I've never used it myself, but I've heard people say favorable things about it.

'Hope that helps .. PSM

MRMadhav 05-18-2006 02:30 AM

Thanks, yes i've searched a bit and i came upon the JavaComm api but it would work only in linux and solaris, Then i found the rxtx api, this one is for windows, mac os x and linux... but the problem is that i don't know how to use it in my app, there are no samples!

MRMadhav 05-18-2006 03:21 AM

ok, i found out some samples from the JavaComm api. I replaced the javax.comm.*; with*; and it worked! The prob is that the sample is very confusing, thought it is working just like the hyper terminal of windows!

All times are GMT -5. The time now is 01:52 AM.