LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-31-2008, 08:01 PM   #1
tasnim
LQ Newbie
 
Registered: Oct 2007
Posts: 18

Rep: Reputation: 0
c++ java


is there analogy of system("cd") command of linux in
java
 
Old 05-31-2008, 08:39 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
No (at least not since the last time I checked). For some reason the java people do not think it necessary to have a chdir() function. I think there is some hack involving “System.setProperty("user.dir")” but this has other, unexpected side-effects.
 
Old 05-31-2008, 09:26 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
'system ("cd")' on Windows will change your processes directory.

The same 'system ("cd")' on Linux won't. "System()" spawns a subshell ... the subshell changes directory (leaving the parent process unaffected) ... and when "system()" exits, the parent's directory is precisely the same as before. 'system ("cd")' is effectively a no-op on Linux.

Osor is correct in discouraging you from trying "user.dir".

Here's a good explanation about why Java works the way it does:
http://www.devx.com/tips/Tip/13804
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 02:13 AM
Ubuntu 7.10 64bit - how to set java path to/redirect java to libjvm.so ? Thane Ubuntu 1 03-25-2008 05:52 PM
LXer: Java news met with cautious optimism in free Java community LXer Syndicated Linux News 0 11-14-2006 10:21 PM
Firefox refuses to load Java jnlp files - plugin and java ok Melsync Linux - Software 1 06-25-2006 04:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration