Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which java classes deals with chmod, chown, etc

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all,
I need to activate the following unix commands in a Java application:

- df for checking the available disk space.
- test -x for checking if a file has execute permission.
- chmod to change a file permissions
- chown to change a file owner
- ln -s to create a link
- uname to find the local host
-who am i to find the local user.

Are there any Java methods deals with it ?

 
Hi.

I don't think Java is the good way to perform unix commands, since it is supposed to be independant from OS.
However, you can execute these commands whith the Runtime class, like this :

...
Runtime rt = Runtime.getRuntime ();

tr.execute ("your command");
...

Bye. --
Globos
 
hi globos,
well..er...i dont know unix as much...but do that Runtime class commands really activate the unix commands as well esp the file access permissions that mayay is talking about
 
most of those commands will have to use the runtime.execute. the File object in java is the best way to tackle file issues but what u are looking for goes well beyond its capibilities.

For the variables that are never going to change i.e. whoami and uname, you should consider setting them as variables in your start script and passing them in as parameters to your application either as direct params to the main or using the -D switch for the JVM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top