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!

Need help implementing cd command

807588Apr 30 2009 — edited May 1 2009
I am writing a command interpreter in Unix that is suppose to run commands like Unix does. I am using Runtime.exec() to run commands such as dir, ls, echo, etc. However exit and cd are not part of those commands. I managed to implement an exit command, but I need help with the cd. Is there a way to change your directory in java just like the cd command does? I've tried System.setproperty("user.dir", path), but it does not seem to work. Typing in dir just shows me all the files that my program is in. I expect it to show me the files that I changed the directory to.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 29 2009
Added on Apr 30 2009
11 comments
561 views