• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to change the working directory in server

 
Yarlagadda Chandra Dutt
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use the function System.setProperty().but Java 1.2 does not support this fucntion.how can I change the drectory in the server using sockets!!!
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simple answer is that you can't. And there's good reason for it too.
Java is inherently multi-threaded, and servers are almost always very actively multi-threaded. For the idea of "change current directory" to make sense, you would need to have a different "current directory" for each thread, otherwise you could never rely on the "current directory" not having been changed by another thread.
The only common reason for wanting to set the "current directory" is so that you can "exec" system commands which assume the current directory is set to a meaningful value. In this case you can almost always set the current directory explicitly with the command. If this is your situation, consider something like exec("cd /some/likely/place; mycommand").
If the only reason you want to set the "current directory" is so you can use the degenerate form of the File constructor which takes a relative filename, you are out of luck. But you seem to know the full directory path sommehow, so you should use the full path for file references.
Has this helped ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!