1

Is it possible to open a command line from Java application, meaning, I have a GUI (written in Java) and I want a command line window to open up (at a specific location) in some cases. is it possible to implement?

Thanks, Binyamin

asked Nov 21, 2010 at 17:07
10
  • Do you just want to open a cmd window and have it stay there? Commented Nov 21, 2010 at 17:08
  • Duplicate? stackoverflow.com/questions/60904/… Commented Nov 21, 2010 at 17:10
  • I want to open a command line window and run a .bat file automatically, but even open the cmd will be good enough, as long as the user can see it and insert his input. Commented Nov 21, 2010 at 17:12
  • 1
    this might help: stackoverflow.com/questions/666699/… Commented Nov 21, 2010 at 17:13
  • If he wants a platform independent command line then it isn't a duplicate. Commented Nov 21, 2010 at 17:13

1 Answer 1

3

This works (revised solution):

String path = "c:\\";
Runtime.getRuntime().exec(new String[] { "cmd.exe", "/C", "\"start; cd "+path+"\"" });
answered Nov 21, 2010 at 17:10
Sign up to request clarification or add additional context in comments.

1 Comment

This is a comment, not an answer. (But I don't think it's the same question.)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.