Reputation: 669
Assume that I have a java program A. The Java program A needs to call another java program B(jar), passes arguments to it and receives the return value from B. How can I achieve this?
Upvotes: 0
Views: 4764
Reputation: 1252
All we have to do is introduce an entry into the JAR file's manifest (MANIFEST.MF in the JAR's META-INF subdirectory), like
Main-Class: com.tedneward.jars.Hello
All a user has to do to execute the JAR file now is specify its filename on the command-line, via java -jar outapp.jar.
Upvotes: 0
Reputation: 156
The easiest solution would be to have the jar as a build-time dependency and invoke it statically from your code.
Please check this: How to run a jar file from a separate jar file?
The above is more applicable for you compared to Execute another jar in a java program
Upvotes: 1
Reputation: 613
I believe your question is answered here Execute another jar in a java program depending on your runtime environment you may need to specify a path to java and/or the jar file
Upvotes: 0