Pedro
Pedro

Reputation: 4160

How to show console window when executing external jar?

When starting an external Java application, I'd also like to see the console window. From what I've read this should be possible when executing cmd /c start xyz. However, by using the following code, I am getting the error message "Windows cannot find '-jar'".

String s = "cmd /c start \"C:/Program Files (x86)/Java/jre6/bin/java.exe\" -jar myjar.jar param1=x param2=y";
Process proc = Runtime.getRuntime().exec(s); 

If start isn't included the application is executed, but the window isn't shown.

Upvotes: 1

Views: 1983

Answers (1)

David
David

Reputation: 20063

The following should run correctly

String s = "cmd /c start \"C:/Program Files (x86)/Java/jre6/bin/java.exe\" java -jar myjar.jar param1=x param2=y";

Upvotes: 2

Related Questions