Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rxtx linux InstantiationException

38 views
Skip to first unread message

Bill Michaelson

unread,
May 16, 2002, 4:14:17 PM5/16/02
to
Trying to run the RXTX package for serial port support on my RH7.1
system. Using the 1.5 .so lib. I think I have everything in place, but
I must be missing something. Here is the problem...

$ java -classpath BlackBox.jar:/home/java/comm.jar BlackBox
Caught java.lang.InstantiationException: javax.comm.CommDriver while
loading driver javax.comm.CommDriver
No serial ports found!

Any hints?

Roedy Green

unread,
May 16, 2002, 6:02:22 PM5/16/02
to
On Thu, 16 May 2002 20:14:17 GMT, Bill Michaelson <bi...@cosi.com>
wrote or quoted :

>$ java -classpath BlackBox.jar:/home/java/comm.jar BlackBox
>Caught java.lang.InstantiationException: javax.comm.CommDriver while
>loading driver javax.comm.CommDriver
>No serial ports found!

When you installed Linux, at some point don't you have to say
something about your serial ports? Perhaps you never did that. Can
you copy a file to a serial port in Linux? If not you want to get
that configured first.

It has been a while since I used Linux, but I seem to recall there is
a tool that gives you an overview of your devices.

Check up on what you need to do to configure dev/ttyS0, aka COM1:.

You can check that your com ports are configured in the standard way
with my little DOS utility UART.COM

http://mindprod.com/products.html#UART


--
The answers to most beginner Java questions are in the
Java glossary indexed and cross-indexed by keyword.
It is usually faster to look them up there than ask
here and wait for a response. See:
http://www.mindprod.com/jgloss.html
or http://209.139.205.39/jagg.html

-
eagerly seeking telecommuting programming work.
canadian mind products, roedy green

Bill Michaelson

unread,
May 16, 2002, 7:18:43 PM5/16/02
to
I developed, sell and support software which is written in C and
requires a serial port. This software is installed on the system in
question and has been using /dev/ttyS0 successfully. So I know the
serial port is present and working properly. I stopped the process
which uses the serial port before trying to run the BlackBox java app to
demonstrate the RXTX functionality.

After I posted my question, I reexamined some other posts on USENET, and
noted some confusion on my part. I should have been using the RXTX 1.4
version in combination with the Sun solaris/86 comm.jar. Also, I had
assumed that my properties file should indicate the corresponding
driver, and so I placed the following line in the file:

Driver=javax.comm.CommDriver

But this only causes the instantiation error as previously described.
When I remove the line, it just silently fails by detecting no serial
ports. If I explicitly specify a port with the -p option of the
BlackBox program, it does not detect the port, regardless of what
permutation I use to specify a device path.

I assume that it is not appropriate to use:

Driver=gnu.io.RXTXCommDriver

...with the 1.4 .so, but I'm not sure. I tried it anyway. This yields
a ClassCastException as follows, which I suppose is reasonable...

$ java -classpath
BlackBox.jar:/home/java/comm.jar:/home/java/RXTXcomm.jar BlackBox -p
/dev/ttyS0
Caught java.lang.ClassCastException: gnu.io.RXTXCommDriver while loading
driver gnu.io.RXTXCommDriver
Port /dev/ttyS0 not found!
No serial ports found!


I'm at a dead-end. I hope Trent Jarvi reads this newsgroup.

Thanks for your input.

Bill

Juergen Kreileder

unread,
May 16, 2002, 8:38:08 PM5/16/02
to
Bill Michaelson <bi...@cosi.com> writes:

> I assume that it is not appropriate to use:
>
> Driver=gnu.io.RXTXCommDriver
>
> ...with the 1.4 .so, but I'm not sure. I tried it anyway. This
> yields a ClassCastException as follows, which I suppose is
> reasonable...
>
> $ java -classpath
> BlackBox.jar:/home/java/comm.jar:/home/java/RXTXcomm.jar BlackBox -p
> /dev/ttyS0
> Caught java.lang.ClassCastException: gnu.io.RXTXCommDriver while
> loading driver gnu.io.RXTXCommDriver
> Port /dev/ttyS0 not found!
> No serial ports found!

rxtx-1.5 replaces the Sun's CommAPI entirely. Either get rxtx-1.4
which is an add-on to Sun's comm.jar or do "sh contrib/ChangePackage
javax" as the rxtx-1.5 suggests in its INSTALL file:

,----[ rxtx-1.5-9pre7/INSTALL ]
| A note about rxtx 1.5:
|
| rxtx 1.5 replaces the entire CommAPI. Every effort is made to conform
| to CommAPI but out of respect for our friends at Sun the package name
| of 1.5 has been moved to gnu.io. A script is offered in
| contrib/ChangePackage.sh that will switch source tree's between
| gnu.io and javax.comm.
`----

Another option you have with rxtx-1.5 is changing "import
javax.comm.*;" to "import gnu.io.*;" in your source code.


Juergen

--
Juergen Kreileder, Blackdown Java-Linux Team
http://www.blackdown.org/java-linux.html
Run Java 2 SE v1.3.1 on your iPAQ:
http://www.handhelds.org/pipermail/ipaq/2001-June/007221.html

Bill Michaelson

unread,
May 16, 2002, 9:08:17 PM5/16/02
to
I assume you mean the libSerial-1.4.15.so lib when you say rxtx-1.4. Am
I right? If so, it would appear that is what I have done, in order to
use the Sun-supplied comm.jar. Is there something else I need to do?

Juergen Kreileder

unread,
May 16, 2002, 9:33:25 PM5/16/02
to
Bill Michaelson <bi...@cosi.com> writes:

> I assume you mean the libSerial-1.4.15.so lib when you say rxtx-1.4.

I mean the complete 1.4 stuff. Note that there is no RXTXcomm.jar in
rxtx v1.4.

>>>...with the 1.4 .so, but I'm not sure. I tried it anyway. This
>>>yields a ClassCastException as follows, which I suppose is
>>>reasonable...
>>>
>>>$ java -classpath
>>>BlackBox.jar:/home/java/comm.jar:/home/java/RXTXcomm.jar BlackBox

^^^^^^^^^^^^

RXTXcomm.jar only exists in rxtx v1.5, ie. you have used the 1.5 classes
here, you should use jcl.jar instead.

>>>-p /dev/ttyS0 Caught java.lang.ClassCastException:
>>>gnu.io.RXTXCommDriver while loading driver gnu.io.RXTXCommDriver
>>>Port /dev/ttyS0 not found! No serial ports found!

> Am I right? If so, it would appear that is what I have done, in


> order to use the Sun-supplied comm.jar. Is there something else I
> need to do?

Just use the correct jar with 1.4.

(If you want to use 1.5 you don't needs Sun's comm.jar but you either
have to use gnu.io instead of javax.comm in your code or to change the
package names in the rxtx source code to javax.comm.)

Bill Michaelson

unread,
May 16, 2002, 11:59:41 PM5/16/02
to

Juergen Kreileder wrote:

> Bill Michaelson <bi...@cosi.com> writes:
>
>
>>I assume you mean the libSerial-1.4.15.so lib when you say rxtx-1.4.
>>
>
> I mean the complete 1.4 stuff. Note that there is no RXTXcomm.jar in
> rxtx v1.4.
>

I was missing the jcl.jar, apparently. Now it goes a little further.
It apparently recognizes serial ports, but later on it...

$ java -classpath BlackBox.jar:/home/java/comm.jar:/home/java/jcl.jar
BlackBox
Exception in thread "main" java.lang.VerifyError: (class:
gnu/io/RXTXPort$SerialOutputStream, method: write signature: ([BII)V)
Illegal use of nonvirtual function call
at gnu.io.RXTXPort.<init>(RXTXPort.java)
at gnu.io.RXTXCommDriver.getCommPort(RXTXCommDriver.java)
at javax.comm.CommPortIdentifier.open(CommPortIdentifier.java:547)
at SerialPortDisplay.openBBPort(SerialPortDisplay.java:153)
at SerialPortDisplay.<init>(SerialPortDisplay.java:125)
at BlackBox.addPort(BlackBox.java:294)
at BlackBox.main(BlackBox.java:240)

Clue?

Juergen Kreileder

unread,
May 17, 2002, 12:40:49 AM5/17/02
to
Bill Michaelson <bi...@cosi.com> writes:

What version of Java did you use to compile rxtx? Which one to run
it? I've just tried Blackbox with our 1.3.1 VM and it starts up
without problems.

Laurent Vaills

unread,
May 17, 2002, 12:05:50 PM5/17/02
to

Hi.

I just have exactly the same exception. I am using Redhat 7.2 and Sun
Microsystems JDK 1.4.0.
Any ideas ?

Laurent

Bill Michaelson

unread,
May 20, 2002, 10:39:15 AM5/20/02
to
Thanks, Juergen, for the feedback. I never discovered what was wrong,
but I built and insatlled the package from source instead of the
distribution binaries. It works properly now, and I have my application
running on the Linux box. I've yet to try it on a Win platform.

My next step is to run it as an applet. I'll be back!

0 new messages