• TwitterFacebookGoogle PlusLinkedInRSS FeedEmail

Javax Comm Usb Serial

03.11.2019 

When you upgrade your older Windows system to the latest Windows 10, or perform updates directly on Windows 10, the Prolific USB to Serial driver also gets update, and if it doesn’t work with your old hardware, you might have the problem. So you can try to downgrade your Prolific USB to Serial driver. Here’s how you can do it. Most projects that deal with hardware and devices, needs to communicate with them using the COM port of the PC or Server. For example if there is a modem that is connected to a server via its COM port and the Java program has to read the output of the modem then the Java program has to read the COM port for any incoming data.

Javaxcomm installation and configuration problems are common. Everytime I configure a new PC it seems there is some new problem waiting to bite - for instance, these: First, check your system environment If the configurations you tried to set up didn't really take place, then of course nothing will work as intended. Typos in system environment variables are a simple example of what can go wrong. So before you get too worried, check your settings. At a command prompt, type 'set' to view all your environment settings and verify that JAVAHOME, etc are actually set to what you intended, and that your JSDK bin folder appears early in the system PATH.

You should see something like this (I've deleted a lot of irrelevant lines): D: set CLASSPATH=D: j2sdk14 lib;D: j2sdk14 lib comm.jar; JAVAHOME=D: j2sdk14 JAVALIB=D: javalib Path=D: j2sdk14 bin;C: PVSW BIN;C: WINDOWS system32;C: WINDOWS;C: WINDOWS System32 Wbem; 'No serial ports found' and errors in the javaxcomm docs or 'where do those silly files.really. need to go'? Recently, running this command line on a new notebook PC installation: C: javalib commapi samples BlackBoxjava -verbose BlackBox resulted in this eventual output: Loaded javax.comm.CommPortEnumerator from file:/C:/Program%20Files/Java/jdk1.5.003/lib/comm.jar No serial ports found!

Usb Serial Number

What's going on here? Java is finding comm.jar but enumeration of serial ports is failing. After some trial and error, and with thanks to Peter Stewart for which confirms others have had the same problem, here is the answer. It seems Windoze JDK is hardcoded to look for properties in jre lib (without regard to where the comm.jar file is located! - you'd think Java would look for the.properties file in the same folder containing comm.jar). The javax.comm.properties file is nothing mysterious - it just lists 'Driver=com.sun.comm.Win32Driver'.

So as long as that Win32Driver class can be found some/any/where in your classpath, javaxcomm is happy. Win32com.dll can go in jre bin too, in spite of what the javaxcomm docs tell you. 2006 July 18: So, bottom line:. Install comm.jar and javax.comm.properties in jre lib. Install win32com.dll in jre bin or in bin and be sure whichever folder you use is in your PATH environment variable.

Javax comm usb serial number

The second choice is maybe best because you need the bin in your path anyway to enable java.exe, javac.exe, javadoc.exe, etc, and you don't need the jre bin folder in your PATH. Add the comm.jar location to your classpath - preferably as a system environment variable. Also be sure the classpath contains a '.' So that the current directory (such as when you run the BlackBox test below) is included. Ignore the javaxcomm javadocs in PlatformSpecific.html, regarding locations of the files mentioned above.

2006 May 04: On a new notebook PC, after doing all the above, BlackBox still fails with a No serial ports found! I decided to try to get a clean and simple installation. I installed the comm.jar and javax.comm.properties in the jre/lib folder and win32com.dll in the jre/bin folder. Then added the jre/lib.comm.jar to the classpath followed by the jdk/bin folder, and the jre/bin to the path. BlackBox fails with Exception in thread 'main' java.lang.NoClassDefFoundError: javax/comm/PortInUseException.

oops, it was a typo in my CLASSPATH variable. Fixed that and now things work as expected. Then to test it, open a command prompt in the BlackBox samples folder (the one containing BlackBox.class) and type 'java BlackBox' Using javaxcomm on a PC with USB but no serial ports USB to serial adapters are cheap and plentiful. I've personally used a Belkin model sold as a PDA synchronization accessory, since they were available cheap at a local office supply store. Follow the USB serial adapter installation instructions provided by that hardware vendor, and BlackBox should report the new device as simply another serial port. This has worked for me on notebook PCs without any serial ports, and on notebook and desktop PCs to add another serial port. You can verify the proper serial port operation and get or set the COM port number in Windows Device Manager on the advanced tab.

USB serial adapters will function as a 'normal serial port' with at least one difference - there is more software latency since the USB driver software adds another intermediate layer to the code which access the UART in the adapter. So you may need to increase timeout values in javaxcomm code which may use a USB serial adapter.

Java finds javaxcomm files in an unexpected place Exception in thread 'main' java.lang.NullPointerException at com.ajile.drivers.serialport.aJileCommDriver.registerWithJavaxComm(aJileCommDriver.java:42) at javax.comm.CommPortIdentifier.getPortIdentifiers(Unknown Source) at BlackBox.main(BlackBox.java:222) This looks strange because you wonder 'what does an aJile driver have to do with BlackBox?' How is the aJile library getting mixed up with BlackBox?

The answer is in the classpath order. In this case on my system it was: CLASSPATH=d: javalib commapi samples BlackBox BlackBox.jar;D: aJile Runtimecldc Rts;D: j2sdk14 lib comm.jar;D: tini1.11 bin; Here the problem is in the order of the classpath folders. BlackBox.jar is listed first, but then the aJile Runtimecldc Rts folder is next.

Since the aJile runtime includes J2ME/CLDC support for javaxcomm, the BlackBox example is trying to use that to run on the PC, and this won't work. Reordering the paths so that the order is BlackBox.jar, then comm.jar, then others fixes this problem: CLASSPATH=d: javalib commapi samples BlackBox BlackBox.jar;D: j2sdk14 lib comm.jar;D: aJile Runtimecldc Rts;D: tini1.11 bin; This points up a weakness in trying to have all your classpaths set up in your system environment.

One ordering may not be what you want all the time. Fortunately there is a solution: the java -cp (classpath) option. For example, instead of adding BlackBox.jar and comm.jar to the environment, add paths to them on the command line: java -cp d: javalib commapi samples BlackBox BlackBox.jar;D: j2sdk14 lib comm.jar; BlackBox or, even better, by using our environment variables: java -cp%JAVALIB% commapi samples BlackBox BlackBox.jar;%JAVAHOME% lib comm.jar; BlackBox Default install puts the JDK in C: Program Files Aargh! On my new notebook I let the JDK install itself where it wanted to - under C: Program Files - note the whitespace.

So now (some) java command line tools fail because 'Program Files' contains white space! For example: C: javalib commapi samplesjava -cp%JAVALIB% commapi samples BlackBox BlackBox.jar;%JAVAHOME% lib comm.jar; BlackBox Exception in thread 'main' java.lang.NoClassDefFoundError: Files Java jdk1/5/003 lib comm/jar; This appears to fail because JAVAHOME expands to JAVAHOME=C: Program Files Java jdk1.5.003 and 'Program Files Java.' Gets delimited to 'Files Java.' However, not all is broken: C: javalib commapi samples BlackBoxjava -verbose BlackBox successfully loads files in the classpath such as: Loaded javax.comm.CommPortEnumerator from file:/C:/Program%20Files/Java/jdk1.5.003/lib/comm.jar so frankly I don't understand what's going on here. Javax/comm/PortInUseException While writing this tutorial, I installed javaxcomm and received this - new to me - error: D: java BlackBox Exception in thread 'main' java.lang.NoClassDefFoundError: javax/comm/PortInUseException I was not using any of the serial ports, so what could this mean?

I started by using the -verbose switch. Systronix® 939 Edison St, Salt Lake City, Utah, USA 84111 Tel +1-801-534-1017, Fax +1-801-534-1019 Time Zone: MDT (UTC-6) Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc.

And other countries. Systronix is independent of Sun Microsystems, Inc. TStik, JStik, JCX, JStamp, JSimm, JDroid, and JRealTime are trademarks of Systronix, Inc. 1-Wire, iButton and TINI are trademarks of Dallas Semiconductor Simmstick is a trademark of Dontronics LEGO® is a trademark of Lego A/S, Denmark.

Click to expand. I have used the javax.comm api to communicate with a GPS receiver using a USB-to-serial adapter on a PC running windows and have not had any problems.

The only thing I noticed is that the port number is variable so you need to programmatically determine which com port the usb-to-serial device is registered on. For example, if you plug in the adapter it might register as com5.

If you unplug it and plug it back into the same USB port, it would register as com6 (at least this is the sort of behavior that I saw). I dealt with this programmatically by enumerating over the available serial ports and checking if the device on the current port was the device of interest. I also used rxtx to do communications when running linux and did not have any problems using an adapter.

Good luck, p. I have used the javax.comm api to communicate with a GPS receiver using a USB-to-serial adapter on a PC running windows and have not had any problems. The only thing I noticed is that the port number is variable so you need to programmatically determine which com port the usb-to-serial device is registered on. For example, if you plug in the adapter it might register as com5. If you unplug it and plug it back into the same USB port, it would register as com6 (at least this is the sort of behavior that I saw). I dealt with this programmatically by enumerating over the available serial ports and checking if the device on the current port was the device of interest. I also used rxtx to do communications when running linux and did not have any problems using an adapter.

Good luck, p.

2019 © logobossfarm