-2

I am trying to run a .cmd program from Java. Doesn't run. I'm using Runtime.exec as advised in some other posts.

public void mouseClicked(MouseEvent arg0) {
  Runtime runtime = Runtime.getRuntime();

  String path = "E:/Marvin/Marvin_Cleanup.CMD";

  try {
    runtime.exec(path);
  } catch (Exception e1) {
    e1.printStackTrace();
  }         
}
user2885431
  • 37
  • 1
  • 4

2 Answers2

0

Im not familiar with windows executeables but using the process builder combined with that url should work fine. http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html

Liebertee
  • 88
  • 9
0

If you call further batches from your batch file you might need to use cmd /c prefix. https://superuser.com/questions/712279/commands-run-in-a-batch-file-only-when-writing-cmd-c-before

String path = "cmd /c E:/Marvin/Marvin_Cleanup.CMD";
Community
  • 1
  • 1
Laszlo Hirdi
  • 1,140
  • 12
  • 18