Reputation: 5124
How can I start a Java application from within a C++ process?
I don't want to invoke just some parts of the Java application, as could be done with JNI, but actually run the whole Java application.
Upvotes: 3
Views: 362
Reputation: 1716
Yes, you can follow the steps at this link: http://java.sun.com/docs/books/jni/html/invoke.html
Note that the sample invokes the "main" method of the loaded class so it would be just as if you did something like java -jar app.jar where the manifest in app jar specifies a main class that loads and starts the app.
Upvotes: 2
Reputation: 81694
Sure, easily:
system("java ClassName");
You can certainly get fancier than that, adding environment variables for CLASSPATH
or whatever else you need. The details of doing so may be moderately system dependent, however.
Upvotes: 1