How do you execute a JAR file within your source code?
I know that for an exe, you use
try
{
Runtime rt = Rintime.getRuntime() ;
Process p = rt.exec("Program.exe") ;
InputStream in = p.getInputStream() ;
OutputStream out = p.getOutputStream ();
InputSream err = p,getErrorStram() ;
//do whatever you want
//some more code
p.destroy() ;
}catch(Exception exc){/*handle exception*/}
Is it the same only:
rt.exec("program.exe") changes to rt.jar("program.jar") or is it something different?
In order to extract a jar file instead of exec(“program.exe”) you need to say
Usually the jar command is available in your bin directory and if the env variables are properly set , you can even say
exec(“jar -xf program.jar”)
For running the jar file you can say “java -jar program.jar”