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

Signature
Steve Sobol, Victorville, California PGP:0xE3AE35ED
"Drench yourself in words unspoken / Live your life with arms wide open
Today is where your book begins / The rest is still unwritten"
- Natasha Beddingfield
Gordon Beaton - 20 Aug 2007 08:16 GMT
> I was wondering if I could do something like
>
[quoted text clipped - 4 lines]
> 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
--
Steve Sobol - 20 Aug 2007 15:17 GMT
> 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.

Signature
Steve Sobol, Victorville, California PGP:0xE3AE35ED
"Drench yourself in words unspoken / Live your life with arms wide open
Today is where your book begins / The rest is still unwritten"
- Natasha Beddingfield
Roedy Green - 20 Aug 2007 11:52 GMT
>java -jar myApp.jar
>from the C++ program?
JNI lets C++ call Java or the reverse. C++ also has an exec so it
can spawn an entire new JVM too.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com