Running Command Line in Java

Ataman picture Ataman · Dec 13, 2011 · Viewed 275.5k times · Source

Is there a way to run this command line within a Java application?

java -jar map.jar time.rel test.txt debug

I can run it with command but I couldn't do it within Java.

Answer

kol picture kol · Dec 13, 2011
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("java -jar map.jar time.rel test.txt debug");

http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html