Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

JNI and jar files

Thread view: 
Steve Sobol - 19 Aug 2007 20:41 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.