• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Have anyone try this code?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did any one try the following example code from the link http://www-900.ibm.com/developerWorks/cn/education/java/j-jni/tutorial_eng/index3.html
I have try to compile and run it under linux...but it has core dump problem
Did anyone successfully compile and run it?
#include <jni.h>
#ifdef _WIN32
#define PATH_SEPARATOR ';'
#else
#define PATH_SEPARATOR ':'
#endif
int main()
{
JavaVMOption options[1];
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
long status;
jclass cls;
jmethodID mid;
jint square;
jboolean not;
options[0].optionString = "-java.class.path=.";
memset(&vm_args, 0, sizeof(vm_args));
vm_args.version = JNI_VERSION_1_2;
vm_args.nOptions = 1;
vm_args.options = options;
status = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
if (status != JNI_ERR)
{
cls = (*env)->FindClass(env, "Sample2");
if(cls !=0)
{ mid = (*env)->GetStaticMethodID(env, cls, "intMethod", "(I)I");
if(mid !=0)
{ square = (*env)->CallStaticIntMethod(env, cls, mid, 5);
printf("Result of intMethod: %d\n", square);
}
mid = (*env)->GetStaticMethodID(env, cls, "booleanMethod", "(Z)Z");
if(mid !=0)
{ not = (*env)->CallStaticBooleanMethod(env, cls, mid, 1);
printf("Result of booleanMethod: %d\n", not);
}
}
(*jvm)->DestroyJavaVM(jvm);
return 0;
}
else
return -1;
}
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic