P
Praetorian
Hi,
I'm trying to locate a Java class from a C++ method using FindClass
but it always fails. FindClass succeeds if I change the argument from
my class name to "java/lang/String" so it seems the class loader
cannot locate my class. Here's my setup:
I have 3 class files:
C:\Work\jni\test\src\CANTest.java
C:\Work\jni\test\src\com\CompanyName\util\CANUSB.java
C:\Work\jni\test\src\com\CompanyName\util\CANMessage.java
CANTest.java only contains a main() function that launches a JPanel,
initializes the CANUSB class and uses it. The CANUSB class loads a DLL
to access functions from another 3rd party DLL. The .class files are
in the following directories:
C:\Work\jni\test\bin\CANTest.class
C:\Work\jni\test\bin\com\CompanyName\util\CANUSB.class
C:\Work\jni\test\bin\com\CompanyName\util\CANMessage.class
I'm calling the CANTest class using the following command
java -classpath C:\Work\jni\test\bin CANTest
The program works fine until the native method that invokes FindClass
is called. This call is as follows:
jclass canMsgCls = jEnv->FindClass( "com/CompanyName/util/
CANMessage" );
While googling this I found people complaining about FindClass
returning NULL but that doesn't happen in my case. The call results in
an exception being thrown before the function returns. The exception
is always thrown in
SetByteArrayRegion which FindClass seems to be calling.
What am I doing wrong here?
Thanks in advance for your help,
Ashish.
I'm trying to locate a Java class from a C++ method using FindClass
but it always fails. FindClass succeeds if I change the argument from
my class name to "java/lang/String" so it seems the class loader
cannot locate my class. Here's my setup:
I have 3 class files:
C:\Work\jni\test\src\CANTest.java
C:\Work\jni\test\src\com\CompanyName\util\CANUSB.java
C:\Work\jni\test\src\com\CompanyName\util\CANMessage.java
CANTest.java only contains a main() function that launches a JPanel,
initializes the CANUSB class and uses it. The CANUSB class loads a DLL
to access functions from another 3rd party DLL. The .class files are
in the following directories:
C:\Work\jni\test\bin\CANTest.class
C:\Work\jni\test\bin\com\CompanyName\util\CANUSB.class
C:\Work\jni\test\bin\com\CompanyName\util\CANMessage.class
I'm calling the CANTest class using the following command
java -classpath C:\Work\jni\test\bin CANTest
The program works fine until the native method that invokes FindClass
is called. This call is as follows:
jclass canMsgCls = jEnv->FindClass( "com/CompanyName/util/
CANMessage" );
While googling this I found people complaining about FindClass
returning NULL but that doesn't happen in my case. The call results in
an exception being thrown before the function returns. The exception
is always thrown in
SetByteArrayRegion which FindClass seems to be calling.
What am I doing wrong here?
Thanks in advance for your help,
Ashish.