Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting ports on Windows OS

 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I am trying to put together a test App that communicates with COM3 on a Windows O/S, so that I can transfer data from the device attached to COM3 to the PC.
I have had a little look around and found a bit of sample code like below that should list the PC ports. It uses a JAR file called RXTXcomm.jar

But when I run the app I get the following error:-


This is my test app:


Any ideas? Or any suggestions of another way to do this?
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas? Or any suggestions of another way to do this?

Hi Keith

I had tried out similar things in past. Initially I had done 'C' coding and had gathered information about ports and had activated desired ports.
Then we got API on the net called "parport" . Have a look at it.I feel its similar to what you are using.

According to me these API's require proper configuration to be made.Have a look at documentation
once again, you might have missed a simple step.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error indicates, that the required dlls (typically on Windoze) are not found on the path
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes there are a couple of DLLs, not sure where they go, I guess just under Windows/System32 or something.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally would prefer not to touch any of the directories created by the system.
You can always place them in a different directory and modify the PATH system variable to append this directory to the existing path
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just an update on this...

I have managed to get a connection to COM3, but I get an "gnu.io.PortInUseException: Unknown Application" exception. Obviously this means the port is already being used by something, I was just wondering, is there a way I can find out what is using it and if it is the 'application' I'm looking for, how can I access it?

Note: The app/device I'm plugging in, is a portable hard, which I need to be able to access the files on, to copy to the local PC.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am not mistaken "netstat -b" lists all the ports in use along with the names of the applications
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keith SmithA wrote:Yes there are a couple of DLLs, not sure where they go, I guess just under Windows/System32 or something.


You can set the system property java.library.path to the directory that contains the DLLs using the -D switch:

java -Djava.library.path=C:\dir\with\dlls com.mypackage.MyProgram
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic