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") Commented 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. Commented 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.