Posted By:
Viraj_Patil
Posted On:
Wednesday, September 3, 2003 01:19 PM
I am trying to call a C++ function from a java class. The java class compiles and I also get the header file when I run javah on the class but when I try running the app, its throwing exceptions. Here is my java code below, the c++ class is a working piece of code. Please let me know what I might be doing wrong here. The C++ function I am trying to call is : VerifyID(BSTR CalcID, BSTR PublicKey, short *rc) Java class: public class certify { static { try { System.loadLibrary("Certificate"); } catch( UnsatisfiedLinkError x ) { System.out.println("Err
More>>
I am trying to call a C++ function from a java class.
The java class compiles and I also get the header file when I run javah on the class but when I try running the app, its throwing exceptions.
Here is my java code below, the c++ class is a working piece of code.
Please let me know what I might be doing wrong here.
The C++ function I am trying to call is :
VerifyID(BSTR CalcID, BSTR PublicKey, short *rc)
Java class:
public class certify {
static {
try {
System.loadLibrary("Certificate");
}
catch( UnsatisfiedLinkError x )
{
System.out.println("Error in static code");
}
}
certify() {
try {
cplusPtr = initCplusSide();
}
catch( UnsatisfiedLinkError x )
{
System.out.println("Error in certify constructor");
}
}
public native short VerifyId(int cplusPtr, String calcId, String publicKey);
private native int initCplusSide();
private int cplusPtr;
public static void main (String [] args) {
String calcId = "123";
String publicKey = "123456";
short retCode = 0;
try {
certify cert = new certify();
retCode = cert.VerifyId(cert.cplusPtr, calcId, publicKey);
System.out.println("retCode is: "+retCode);
}
catch( UnsatisfiedLinkError x )
{
System.out.println("Error in certify main");
}
}
}
<<Less