aspose file tools*
The moose likes Java in General and the fly likes Getting ports on Windows OS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting ports on Windows OS" Watch "Getting ports on Windows OS" New topic
Author

Getting ports on Windows OS

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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

Joined: Mar 05, 2009
Posts: 117
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.


Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

The error indicates, that the required dlls (typically on Windoze) are not found on the path


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Yes there are a couple of DLLs, not sure where they go, I guess just under Windows/System32 or something.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

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

Joined: Feb 18, 2005
Posts: 362
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

Joined: Jul 26, 2007
Posts: 9990
    
    7

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

Joined: Aug 16, 2005
Posts: 13875
    
  10

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

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting ports on Windows OS
 
Similar Threads
Getting exception in jmagick
Java Telephone API (JTAPI)
Caught java.lang.UnsatisfiedLinkError
Access dll functions in java
no ocijdbc9 in java.library.path in JDK 1.4.2