• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing the working directory

 
mojo lai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applet's default working directory is at "Desktop"

Is there any way to change the working directory to another directory ?
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No there isn't. The working directory is set when the JVM starts, and cannot change afterwards. If it could, then all relative File objects would become mutable, and that's something that's not allowed.

If you're using a file browser, you can always set its default path to search in. With JFileChooser the method is setCurrentDirectory, with FileDialog the method is setDirectory.
 
mojo lai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, but can I change it BEFORE executing a applet ?
[ November 24, 2008: Message edited by: mojo lai ]
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only if you open the applet using appletviewer. Otherwise the browser will set it for you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!