Need help to change default directory. Any Java virtual machine parameter?

Hi all,

I use some java programs, which need JRE 1.5.011.

Using this program i can open a window to perform a download / upload, and a default directory appears (e.g. my documments)

Is there any JVM parameter to define a new default directory? Or any other way to define a new default directory?

Thanks

[333 byte] By [_zZz_a] at [2007-11-27 3:15:22]
# 1

By "default dir" you mean the current working dir? The place where files go if you specify a relative rather than full path?

I think that's in the user.dir System property, but trying to set that on the command line with -D didn't seem to have any effect. You could define your own property, specify it with -D on the command line, and then just prepend that property's value to any file operations you do.

jverda at 2007-7-12 8:17:53 > top of Java-index,Java Essentials,New To Java...
# 2

Thanks for answer.

I think i didn't explain well what i needed.

Imagine you are in Internet explorer. You go to File and choose Save As.

a windows appears, with a default directory for saving files.

what happens is that I use a program made in java, with has a similar window. Every time i open it, I'm prompted to save my files in a default directory.

What I would like to do is somehow change this default directory. I thought JRE could have some option for this!!

Thanks again

_zZz_a at 2007-7-12 8:17:53 > top of Java-index,Java Essentials,New To Java...
# 3
Do you mean JFileChooser? If so, read the API.setCurrentDirectory(File dir)
masijade.a at 2007-7-12 8:17:53 > top of Java-index,Java Essentials,New To Java...
# 4
yes. i think that is it! it must use Jfilechooser.any chance to change it without "Playing" with the code?because i only have access to the executable... that is way i asked if there is any commandline in jvm that could do it
_zZz_a at 2007-7-12 8:17:53 > top of Java-index,Java Essentials,New To Java...
# 5

It defaults to the user home directory. You can try setting

-Dhome.dir="....."

and if that doesn't work, try changing the environment variable for it before starting the process (in *nix it is "HOME", the others I don't know).

Edit: Note though, that this can have other repercussions. If the program uses the Preferences class, then (at least on Unix) the preference entries may have to be newly defined (as they are normally stored as "." files in the users home directory on Unix) among other possible and similar side effects.

masijade.a at 2007-7-12 8:17:54 > top of Java-index,Java Essentials,New To Java...