Turning Servlets into Web Services

It is relatively easy to build Java servlets that can parse and return XML documents with the help of the BorlandXML toolset found in JBuilder Developer and Enterprise editions. BorlandXML provides a mechanism for extracting data from XML documents and creating XML documents using JavaBeans. Read more of this post


Borland To Drop JBuilder

Those of you who’ve read my Java articles know that I’m a big fan of Borland’s JBuilder IDE. Recently, though, my open systems development manager Nick vanMaarth has been working on me to switch to Eclipse. Personally I have nothing against Eclipse…it’s just I’ve been using the JBuilder IDE for a long time and don’t want to learn something new. Well it seems that Borland has helped Nick push me to start using Eclipse. ComputerWorld has recently reported that, as part of its new strategic direction, Borland is selling off it’s development tools such as JBuilder and C++Builder. Don’t be surprised when my next Java articles feature examples developed using Eclipse.

Click here for more on Borland’s stated direction.

The Java Communications API Revisited…

Several months ago I wrote an article for the Borland Developer Network site (http://bdn.borland.com) on the Java Communications API. Since that time I’ve received numerous emails about the article. To those who’ve emailed me, thanks for your kind words.

I’ve compiled the following FAQ based on some of your questions and my responses. If you’re working with the Java Communications API, you might find this useful.

Question 1:
If I’m trying to send a character through serial port communication to another computer how can I verify that the signal was sent?

I used an old WYSE serial terminal and a null modem cable to test the code. Then I set both the serial ports to COM2 (the serial port on my laptop). I also used a separate communications port monitor of the type used for network troubleshooting.

If you have access to another PC with a serial port, you should be able to hook it to the one you’re running the program on (via some serial cables, a null modem adapter, and maybe a gender bender). On the second PC fire up a communications program like HyperTerm or Procomm and set it to communicate on the serial port you’re connected to. This will allow you to send and receive data between the PCs.

Question 2:
Is your code correct?

The code runs correctly using J2SE 1.4 on a Windows 2000/XP. I’ve also run it on Red Hat Linux 7.2 using the RXTX version of the comm.jar (there’s a link to RXTX in the article).

If you compile my example, execute it, and it doesn’t give you any exceptions, it should be working properly. You’ll get exceptions if the program can’t get handles for the COMn devices or if the comm.jar, win32comm.dll, or javax.comm.properties files can’t be found.

Question 3:
is possible to send and receive at commands using java comm?


Question 4:
Does Java send any additional characters with its strings to the serial port?

Java does not send additional characters down the port (I know this because I’ve tested it with a port monitor). It sends what your program sends.

Question 5:
Does Java send the strings in ASCII values to the port?

As far as data encoding is concerned, unless you specify something different, you’ll be sending data in the default encoding of your hardware.

Question 6:
I am trying to send serial data using a usb to serial converter since my laptop does not have a serial port. Problem is, in Windows device manager, the usb to serial converter shows up as “Prolific USB-to-Serial Comm Port (COM4)”, but running
ComControl.java returns:

COM4 null
msg1 – javax.comm.NoSuchPortException

Any suggestions?

I tried the usb to serial port converter that I have (it is a Targus PA090) and it worked properly. On the PA090, the serial port cannot run faster than 9600 baud. You may want to check the baud settings on yours. You may also want to experiment with the stop bits, parity, etc. The PA090 also has a serial port reset button. If your converter has one, try resetting it. Check for the latest drivers also.

Question 7:
I’ve tried running your code and I’m getting a “javax.comm.NoSuchPortException” message. Any clues?

First, check your PC to see if the COMn ports you are using have been defined. Next, check the location of win32com.dll and javax.comm.properties. They are required for the comm API to work properly in a Windows environment. Usually the javax.comm.properites file is the culprit. It needs to be located in the classpath of your java program.

The Java Communications API

Follow the link below to read my article on the Java Communications API posted on the Borland Developer Network.

Java Communications API

%d bloggers like this: