I'm trying to call a java.jar(it is working by double click) from a java application.And it is working with that code below.The main problem is that when the called jar start to work (a gui application), ı cannot use the my main(another gui application) application.I think it is waiting the exec command's end. How can I manage to run this 2 application properly?
public void handle(Event arg0) {
Runtime runTime = Runtime.getRuntime();
try {
Process process = runTime
.exec("java -jar \"D:\\WORKSPACE\\Deploy\\Binary\\XXXX.jar\"");
BufferedInputStream inputStream = new BufferedInputStream(process.getInputStream());
BufferedInputStream errorStream = new BufferedInputStream(process.getErrorStream());
int n1;
byte[] c1 = new byte[4096];
StringBuffer standardOutput = new StringBuffer();
while ((inputStream.read(c1) != -1)) {
standardOutput.append(c1.toString());
}
System.out.println("Standard Output: " + standardOutput.toString());
int n2;
byte[] c2 = new byte[4096];
StringBuffer standardError = new StringBuffer();
while (errorStream.read(c2) != -1) {
standardError.append(c2.toString());
}
System.out.println("Standard Error: " + standardError.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
});