Reputation: 39
I'm trying toopen/execute another program, which is a .jar file, but I'm getting the following error:
it is not a windows application
(java.io.IOException: CreateProcess error=193)
Here is my code:
import java.io.IOException;
public class Test8 {
public static void main(String[] args) {
try {
String filepath = "C://Users//Alex//Desktop//Speedtest.jar";
Process p = Runtime.getRuntime().exec(filepath);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Upvotes: 0
Views: 193
Reputation: 12332
At the command-line, JARs are executed with java -jar
. Try passing a String array:
String[] args = new String[] {"java", "-jar", "/path/to/myJar.jar"};
Process p = Runtime.getRuntime().exec(args);
Upvotes: 1