Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with diskutil command with ProcessBuilder for MAC

Ravi_TejaDec 28 2012 — edited Dec 30 2012
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 27 2013
Added on Dec 28 2012
4 comments
608 views