Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigDecimal;
- public class BigDecimalDemo {
- public static BigDecimal sum(BigDecimal d,String s , BigDecimal b) {
- BigDecimal ans1 = (d.add(b));
- System.out.println("result inside BigDecimalDemo = "+ans1);
- return ans1;
- }
- to call it i use below approch but not able to call the java method :
- int main(int argc, char* argv[])
- {
- JNIEnv *env;
- string result_op = " " ;
- JavaVM * jvm;
- env = create_vm(&jvm);
- int i ;
- if (env == NULL)
- return 1;
- jclass clsH , ClsB =NULL;
- jmethodID midBigD , midMain = NULL;
- ClsB = env->FindClass("java/math/BigDecimal"); // for bigdecimal object
- clsH = env->FindClass("com/fedex/test"); // for my class
- midMain = env->GetMethodID(clsH, "sum", "(Ljava/math/BigDecimal;Ljava/lang/String;Ljava/math/BigDecimal)Ljava/math/BigDecimal");
- midBigD = env->GetMethodID(ClsB, "<init>", "(D)V");
- jobject bd1 = env->NewObject(ClsB, midBigD, 12.1234);
- jobject bd2 = env->NewObject(ClsB, midBigD , 0.0500);
- jstring StringArg2 = env->NewStringUTF("STD");
- jobject result = env->CallObjectMethod(clsH, midMain,bd1,StringArg2,bd2 ); //Calling the method.
- printf(" print the resultn ");
- //Release resources.
- int n = jvm->DestroyJavaVM();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement