• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in calling java application into C

 
Satheesh Thurairajah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am trying to call a call java application into C code so that it can be run as NT Service. For this I am following the below mentioned way:
JNI_GetDefaultJavaVMInitArgs(&vm_args);
jint res;
/* Append USER_CLASSPATH to the end of default system class path */
sprintf(classpath, "%s%c%s",MY_CLASSPATH, PATH_SEPARATOR, USER_CLASSPATH);
vm_args.classpath = classpath;
/* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
vm_args.version = 0x00010001;
res = JNI_CreateJavaVM(&jvm,(void**)&env, &vm_args);
Here when I run this, I getting a null value for the instance value for the jvm instance value.
Could anyone tell me what will cause for the above and what will be the remide for this?
Thanks in advance,
Satheesh
 
Todd Fisher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If all you are doing is trying to call a java application
from your C program just try using the
system function, nothing fancy, and pass it your a string
formated just as it would appear at the command prompt...
that is of course if this is what you mean i'm a little
confused by what you are asking.
 
Satheesh Thurairajah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Todd for your reply..
But what I expect is not the one that is included in your reply (sorry if I couldn't explain in detail..)
The problem is not calling the application. As It should be run as NT Service, I want to use it's full features so that it could be controlled through the Service Control Manager (SCM). And at the same time I could pass the signals here and there from C++ to java as well.
For this I am creating an instance of the JVM so that it could be possible to handle the event through the execution of java classes.
In my code, it compiles without any problem, but during runtime, it is not creating an instance to the JVM so that it is crashing.
I think I have detailed my problem.
Thanks again,
Satheesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic