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
MByD
138k30 gold badges269 silver badges278 bronze badges
-
Do you just want to open a cmd window and have it stay there?wkl– wkl2010年11月21日 17:08:57 +00:00Commented Nov 21, 2010 at 17:08
-
Duplicate? stackoverflow.com/questions/60904/…dacwe– dacwe2010年11月21日 17:10:54 +00:00Commented 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.MByD– MByD2010年11月21日 17:12:37 +00:00Commented Nov 21, 2010 at 17:12
-
1this might help: stackoverflow.com/questions/666699/…Zevan– Zevan2010年11月21日 17:13:27 +00:00Commented Nov 21, 2010 at 17:13
-
If he wants a platform independent command line then it isn't a duplicate.Goran Jovic– Goran Jovic2010年11月21日 17:13:54 +00:00Commented Nov 21, 2010 at 17:13
1 Answer 1
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
dacwe
43.5k12 gold badges118 silver badges142 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
T.J. Crowder
This is a comment, not an answer. (But I don't think it's the same question.)
lang-java