• Post Reply Bookmark Topic Watch Topic
  • New Topic

javax.comm

 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the javax.comm on XP with sun's NetBeans IDE 3.6. I've found a lot of help on setting up the javax.comm correctly. My program works and will find my ports correctly if I run it from the IDE. However, I've moved the files into a jar and now it won't find any ports. Also, If I move the jar to another computer (that can run jars) it seems like the program just dies. Javaw is running under the task list but no windows open. I'm not that comfortable with jar files yet, but I have several others I tested out on the both computers. I don't receive any errors in the IDE when compiling or executing. Anyone else have this happen? code below. Thanks.

my jar contains:
XportMonitor
portWatch
javax.comm.properties[tried without]
javax.comm.jar[tried without]
win32com.dll[tried without]

this is only a modified version of the simple read that comes with the api.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't the properties file and .dll need to be in a specific location on the disk, rather than in the JAR, in order for it to run?
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the ide yes- I had to put them in specific locations. The jar would run in my IDE even if I only had the two class files in the jar. But it wouldn't find any ports. if your familiar with netbeans - I made my jar execution path the same as my external execution path too - that didnt work either.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben's right. From the Java Comm API FAQ:

Q: BlackBox gives me a message that says "No serial ports found!"

A: In order for the Java communications API to find ports the file javax.comm.properties must be in the correct place. The preferred location is in <jdk>/lib. See the installation instructions for alternate locations and further information.

Since it works in NetBeans, it may be that you are running a one VM inside the IDE and a different version on the outside.
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so would the jar be looking for these files on the other computer also ? and how would I find out what the path should be?
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rich Step:
so would the jar be looking for these files on the other computer also ?

Yes. BTW, you can't include a nested JAR file inside your JAR. You will need to extract the contents of the comm.jar file and roll them up into your application's JAR.

and how would I find out what the path should be?

What path are you talking about?
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for the properties file - but I guess I wouldn't need that because I could put the javax.comm jar in my application's jar?
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also - how do I extract the contents of jar file? I can view it in NetBeans, would this just be a copy and paste into another folder from within NetBeans?
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rich Step:
for the properties file - but I guess I wouldn't need that because I could put the javax.comm jar in my application's jar?


Did ya read the line from the FAQ that stated:
In order for the Java communications API to find ports the file javax.comm.properties must be in the correct place. The preferred location is in <jdk>/lib


You need that properties file in the JDK\lib directory.



how do I extract the contents of jar file?



Or you can use WinZip or whatever file compression utility you have handy. JAR's are just Zip files with some bells and whistles.
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In order for the Java communications API to find ports the file javax.comm.properties must be in the correct place. The preferred location is in <jdk>/lib


The program works and finds ports in the IDE. When run from a jar inside or out of the IDE it doesn't.

I'll try to add the api jar to my jar after unzipping it and see what happens. Thanks a lot for the help.
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
combining the javax.comm jar with my jar didn't solve my problem....
however I did figure out how to do it with help from a Mr. Brogen...

I think there are three possible reasons - which I'm sure you have already
considered, but anyway:
1. the comm.jar is not being found
2. the DLL isn't being found and loaded
3. the comm.properties file is not being found

Since 1 & 2 would produce error message, I'm betting on 3 - It is my
understanding that
javax.comm.properties has to be located by the JVM at the ../lib directory
relative to the /bin directory where javaw starts from. This has nothing to
do with where your jar file lives.

(Thats one reason I prefer to stay away from IDEs - they do things behind
your back
and don't tell you about them.)

Bill

--
Java Goodies at http://www.wbrogden.com/


Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!