My problem is when to call jar file using
Runtime.getRuntime().exec() method, my .jar is not executing and showing its output
Coding is like that
public static void main(String[] args) {
String execJar = "java -jar C:\test.jar"; try { Process p = Runtime.getRuntime().exec(execJar); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
When I used this "java -jar C:\test.jar" in command prompt, my .jar is not executing thus not showing System.out output. Does anybody know how I can make this work?
Thanks.
Process
! Do yourself a favor and go through the Java World article linked from theexec
info. page. It might not solve the problem, but at least you will have more information. After that, split the arguments into aString[]
and use aProcessBuilder
to create theProcess
. – Andrew Thompson