How to use chmod from java code

I have created a directory as a root user inside the home of other user. i want to change the ownership of that directory, from java code. How can i do this?

[164 byte] By [Mohamed_Thasneema] at [2007-11-27 11:03:56]
# 1

Using either native code or running a shell command to do it through Runtime

georgemca at 2007-7-29 12:54:26 > top of Java-index,Java Essentials,New To Java...
# 2

use:

http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html

use exec method of this class.

AshwineeJhaa at 2007-7-29 12:54:26 > top of Java-index,Java Essentials,New To Java...
# 3

So i will have to use the Runtime class and execute the required command.

Mohamed_Thasneema at 2007-7-29 12:54:26 > top of Java-index,Java Essentials,New To Java...
# 4

> So i will have to use the Runtime class and execute

> the required command.

That's your best bet, yes. Java doesn't have a way to do this. Have a look around Sourceforge and the like, see if there exists a library that manipulates *nix file permissions from Java, wouldn't surprise me if there was

georgemca at 2007-7-29 12:54:26 > top of Java-index,Java Essentials,New To Java...
# 5

tanku guys. got it to work with exec

Mohamed_Thasneema at 2007-7-29 12:54:27 > top of Java-index,Java Essentials,New To Java...
# 6

> tanku guys. got it to work with exec

Sweet! Would you mind posting the code in case someone else has the same problem in the future?

georgemca at 2007-7-29 12:54:27 > top of Java-index,Java Essentials,New To Java...