This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Formatting drive with java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Formatting drive with java." Watch "Formatting drive with java." New topic
Author

Formatting drive with java.

Carlton Hanna
Greenhorn

Joined: Jul 29, 2009
Posts: 6
I'm running java on a ubuntu server, is there a way I can have java format a disk drive(/dev/sd*) to ext3?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

You can use ProcessBuilder and Process to call an external command. See http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/ref-guide/s1-filesystem-ext3-create.html
And while you're at it, read the Javaworld article "When Runtime.exec() won't".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

using java for systems programming is a bad idea,

In simple words, java cant do it, It can invoke another program to do it as Rob Prime said,
But if you think that java can write "0" and "1" to the disk directly and do the formatting work, you are mistaken.

Since you mention server,
what is your aim?
- is it to remotely send a command to this server that triggers a partition format ?
- is it to format itself after some timely schedule ?

both the above options can be solved by using the underlying OS: Ubuntu


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Formatting drive with java.