Reputation: 77
I am trying to run a .bat file from my java code and I'm using the ProcessBuilder.java functionality as follows:
String[] hubCmd = new String[]{"cmd.exe", "/C", "startHub.bat"};
ProcessBuilder pbHub = new ProcessBuilder(hubCmd);
pbHub.directory(new File("C:\\java\\selenium\\"));
Process hubP = pbHub.start();
This seems to work, kicks of a java process and associated cmd process, but the command window is not displayed. Am I missing something or is this correct functionality?
Thanks in advance.
Upvotes: 2
Views: 1655
Reputation: 31290
Java's Process is meant to execute a command, and so it does with cmd.exe.
What you see is correct. cmd.exe does not have a "feature" for displaying a window.
The "window" you normally see is a terminal emulation or some such thing which in turn (like your Java program!) can execute another program, i.e., cmd.exe
It is the same with Linux, where an xterm executes a shell (the command interpreter). No shell (in the classic style) can display a "window".
You can make your Java program the "window"!
Upvotes: 3