Question

I am trying to develop a Java tool to refactor css files. I am trying to access the command prompt from Java. The command prompt is opening fine but it's not running the csstidy exe file.

try {

  String command = "cmd /c start cmd.exe /K \"cd C:/Users/BS11040/Desktop/CSSTIDY_JAVA/";

  Process child = Runtime.getRuntime().exec(command);

  OutputStream out = child.getOutputStream();

  out.write("csstidy.exe /r/n".getBytes());
  out.flush();
  out.close();

} catch (IOException e) {

  e.printStackTrace();

}

No correct solution

OTHER TIPS

Try invoking your .exe directly, you are doing it way to complicated:

String command = "C:/Users/BS11040/Desktop/CSSTIDY_JAVA/csstidy.exe";
Process child = Runtime.getRuntime().exec(command);

And by the way, the codes for CR and NEWLINE are \n and \r , take care to use the right slash!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top