This discussion is archived
4 Replies Latest reply: Dec 30, 2012 6:21 AM by baftos RSS

Problem with diskutil command with ProcessBuilder for MAC

Ravi_Teja Newbie
Currently Being Moderated
Hi

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"};
or
String[] srt = new String[]{"diskutil eraseDisk","exFAT","Test","NewName"};
or
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,
Ravi

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

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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points