wood burning stoves 2.0*
The moose likes Java in General and the fly likes Problem in calling java application into C Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in calling java application into C " Watch "Problem in calling java application into C " New topic

Problem in calling java application into C

Satheesh Thurairajah

Joined: Aug 20, 2001
Posts: 2
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:
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,
Todd Fisher

Joined: Aug 21, 2001
Posts: 3
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

Joined: Aug 20, 2001
Posts: 2
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,
jQuery in Action, 2nd edition
subject: Problem in calling java application into C
Similar Threads
Calling java from Visual C
problem of C++ Call java with JNI
Undefined reference in JNI
Here is how to create process and Image APPName.exe file instead of java or javaw
Invoking JVM through C++ code