JNI and jar files

S

Steve Sobol

I have a C++ program that loads and executes a method in a Java class using
the Invocation API. Easy enough to do, but I was wondering if I could do
something like

java -jar myApp.jar

from the C++ program? At the very least, I know what class and method
I'm going to call, so couldn't I just include myApp.jar in the class
path (via "-Djava.class.path=myApp.jar"), load the class and call the
proper method?

Thanks
 
G

Gordon Beaton

I was wondering if I could do something like

java -jar myApp.jar

from the C++ program? At the very least, I know what class and method
I'm going to call, so couldn't I just include myApp.jar in the class
path (via "-Djava.class.path=myApp.jar"), load the class and call the
proper method?

Do you mean including that in the options field of the vm_args
structure passed to JNI_CreateJavaVM?

I would expect it to work, but have never tried. You should be able to
invoke the appropriate main method from the jarfile in the "normal"
way for invocation.

What happened when *you* tried?

/gordon

--
 
S

Steve Sobol

I would expect it to work, but have never tried. You should be able to
invoke the appropriate main method from the jarfile in the "normal"
way for invocation.

What happened when *you* tried?

I subsequently tried it, including the jar file in the classpath, and it
seems to work. There are some issues - but I don't believe they're directly
related to JNI.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top