[Rxtx] even more errors

Ákos Maróy darkeye at tyrell.hu
Wed Oct 26 06:58:40 MDT 2005


Trying to make it really work, I even encountered more errors.

when trying to load the RXTXCommDriver class, I get:

Exception in thread "main" java.lang.NoClassDefFoundError:
javax.comm/CommPortIdentifier
        at gnu.io.RXTXCommDriver.registerKnownPorts(Native Method)
        at gnu.io.RXTXCommDriver.initialize(RXTXCommDriver.java:329)
        at SimpleTest.<init>(SimpleTest.java:29)
        at SimpleTest.main(SimpleTest.java:24)


it turns out that in the JNI code, repeatedly the package names are used
wrongly. in registerKnownSerialPorts(), the following section is wrong:

        jmethodID mid; /* dima */
        cls = (*env)->FindClass(env,"javax.comm/CommPortIdentifier" ); /*
dima */
        if (cls == 0) { /* dima */
            report( "can't find class of javax.comm/CommPortIdentifier\n"
); /* dima */
            return numPorts; /* dima */
        } /* dima */
        mid = (*env)->GetStaticMethodID(env, cls, "addPortName",
"(Ljava/lang/String;ILjavax.comm/CommDriver;)V" ); /* dima */


corrently, the complete name references are:

        jmethodID mid; /* dima */
        cls = (*env)->FindClass(env,"javax/comm/CommPortIdentifier" ); /*
dima */
        if (cls == 0) { /* dima */
            report( "can't find class of javax/comm/CommPortIdentifier\n"
); /* dima */
            return numPorts; /* dima */
        } /* dima */
        mid = (*env)->GetStaticMethodID(env, cls, "addPortName",
"(Ljava/lang/String;ILjavax/comm/CommDriver;)V" ); /* dima */



now I can load RXTXCommDriver, but when trying to use the driver through
the javax.comm API, I still get a ClassCastException:

=========================================
Native lib Version = RXTX-2.0-7pre1
Java lib Version   = RXTX-2.0-7pre1
Caught java.lang.ClassCastException while loading driver
gnu.io.RXTXCommDriver



Akos




More information about the Rxtx mailing list