-5

Possible Duplicate:
Running Command Line in Java

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

cd "C:\Program Files\myfolder\"&&"C:\Program Files\Java\jre6\bin\java.exe" -jar myjar.jar

I can run it with command but i couldnt do it within Java.

Community
  • 1
  • 1

1 Answers1

1

In Java, you can use Runtime.getRuntime().exec("yourcommand") to run command line arguments.

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

I would however suggest using a more portable way of referencing that than what you are currently doing.

You can also use Java 6 Compiler API if you want to load classes at runtime rather than call a java program.

http://www.javabeat.net/2007/04/the-java-6-0-compiler-api/

Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
user1018513
  • 1,682
  • 1
  • 20
  • 42