Search code examples
javacommand-lineruntime.exec

Running Command Line in Java


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.


Solution

  • 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