Question subject: How to connect to serial port using java
Posted: Sat Jun 30, 2007 5:27 pm
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
This is the code of connecting to serial port and writing streams and reading from it .This project was already exists on some page . What i did new is changing the GUI to javax.swing .Here in this project you choose a file to send using JFileChooser Dialog. You can then save it at the receiver.I have to say something that sun have a package called java.comm is used for communication .but i found it only for linux and solary .I didn't find version for windows.So i used native functions that is implemented in c/c++ language. I is also can be found with the project . It is a netBeans project so you will find java codes in src folder .Just remmber to install netbeans to open this project or use java files that exists in src folder.
Attachments:
File comment: the netbeans project of it serialport.rar [550.2 KiB]
Downloaded 8758 times
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
codemiles123
Question subject: Re: How to connect to serial port using java
Posted: Tue Nov 11, 2008 9:50 pm
Joined: Tue Nov 11, 2008 9:34 pm Posts: 1 Has thanked: 0 time Have thanks: 0 time
The link to the serialport.rar file is broken. Is the file still available? Thanks
msi_333
Question subject: Re: How to connect to serial port using java
Posted: Wed Nov 12, 2008 11:08 am
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
codemiles123 wrote:
The link to the serialport.rar file is broken. Is the file still available? Thanks
check the link , again ,
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
acadevterm
Question subject: Re: How to connect to serial port using java
Posted: Mon Sep 14, 2009 11:55 pm
Joined: Mon Sep 14, 2009 11:51 pm Posts: 3 Has thanked: 0 time Have thanks: 0 time
I am getting the following error when I try to run the code in NetBeans 6.5. Anybody know how to fix this?
Initing NATIVE port. Com = \\.\com1, baud = 9600 ###ERROR: You can't get input stream because serial port wasn't opened ###ERROR: You can't get input stream because serial port wasn't opened ###ERROR: Couldn't open requested port preferences file 'JavaTerm.pref' not found / didn't open or there was a problem opening serial port. Searching for serial port Initing NATIVE port. Com = \\.\com1, baud = 9600 ###ERROR: You can't get input stream because serial port wasn't opened ###ERROR: You can't get input stream because serial port wasn't opened ###ERROR: Couldn't open requested port Initing NATIVE port. Com = \\.\com2, baud = 9600 ###ERROR: You can't get input stream because serial port wasn't opened ###ERROR: You can't get input stream because serial port wasn't opened ###ERROR: Couldn't open requested port Couldn't open any serial ports
Thanks for the help.
msi_333
Question subject: Re: How to connect to serial port using java
Posted: Tue Sep 15, 2009 8:19 am
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
i think you have problem with your ports configurations .
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
acadevterm
Question subject: Re: How to connect to serial port using java
Posted: Tue Sep 15, 2009 8:03 pm
Joined: Mon Sep 14, 2009 11:51 pm Posts: 3 Has thanked: 0 time Have thanks: 0 time
So are you saying that this is more of a computer problem than a java problem?? Or is there someway to fix this in the code.
msi_333
Question subject: Re: How to connect to serial port using java
Posted: Wed Sep 16, 2009 2:08 am
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
Yes , because this is what think ! Are you sure that your serial ports are working correctly .
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
acadevterm
Question subject: Re: How to connect to serial port using java
Posted: Wed Sep 16, 2009 8:24 pm
Joined: Mon Sep 14, 2009 11:51 pm Posts: 3 Has thanked: 0 time Have thanks: 0 time
I have used them with other programs and they work fine.
msi_333
Question subject: Re: How to connect to serial port using java
Posted: Sat Oct 03, 2009 12:44 am
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
Does it works now. ? Am just concerned to find the actual problem.
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
vampke
Question subject: Re: How to connect to serial port using java
Posted: Thu Aug 19, 2010 9:03 pm
Joined: Thu Aug 19, 2010 9:01 pm Posts: 1 Has thanked: 0 time Have thanks: 0 time
I have the same problem: I can connect to my device in vb.net, with you program I cannot. Port settings are correct