0

I have jar file(selenium-server-standalone-2.44.0.jar) kept at c:\ drive. I need to navigate to C drive and execute below command through java

java -jar selenium-server-standalone-2.44.0.jar -role hub

2
  • Runtime.exec("cd C:\"); Runtime.exec("java -jar selenium-server-standalone-2.44.0.jar -role hub") Jun 29, 2015 at 14:24
  • Runtime will definitely work. If you want more control (like the ability to handle standard in/out), ProcessBuilder will give you more. Here's some info contrasting the two. Jun 29, 2015 at 14:34

1 Answer 1

3

You can try below code

 Process process  = Runtime.getRuntime().exec("cmd /c start cmd.exe /K java -jar selenium-server-standalone-2.44.0.jar -role hub");

However this will run executable jar from your current directory, where you .class file exist.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.