4 Replies Latest reply: Dec 30, 2012 8:21 AM by baftos RSS

    Problem with diskutil command with ProcessBuilder for MAC


      I am facing difficulty in using diskutil command with Java ProcessBuilder or Runtime.getRuntime().exec().
      The following command is working fine when execute from Mac terminal:
      diskutil eraseDisk exFAT newdisk disk1
      Note: diskutil is the program being run, eraseDisk is the operand, exFAT is the format of the new disk, newdisk is the name of the new disk, and disk1 is the mount point for the disk to be formatted.

      Below are my trails in java with no success :(

      String[] srt = new String[]{"xterm","-e","diskutil eraseDisk exFAT Test NewName"};
      String[] srt = new String[]{"diskutil eraseDisk","exFAT","Test","NewName"};
      String[] srt = new String[]{"diskutil","eraseDisk","exFAT","Test","NewName"};

      ProcessBuilder pb = new ProcessBuilder(srt);
      Process p = pb.start();

      I am getting "java.io.IOException: Cannot run program "xterm": error=2, No such file or directory"

      Can somebody help me regarding the same?

      Thanks in advance,

      Edited by: Ravi_Teja on Dec 28, 2012 3:33 AM

      Edited by: Ravi_Teja on Dec 28, 2012 3:33 AM