SAMP on Windows
Thomas Boch
boch at newb6.u-strasbg.fr
Wed May 14 02:54:39 PDT 2008
Hi,
> Although you'd expect that the user.home system property in java would
> point to USERPROFILE under Windows, it does not (at least up till
> java 1.6). So you have to use the (deprecated) System.getenv() method
> instead and retrieve USERPROFILE directly. Unfortunately, at java 1.4
> getenv is not only deprecated but also unimplemented (it throws a
> java.lang.Error). For later versions (1.5 and 1.6), happily, getenv
> works again. This means that it is basically impossible to obtain
> the value of USERPROFILE if you are running java 1.4 on Windows.
> In this case probably the best thing you can do is to use the
> value of user.home, which may or may not give you the right answer.
Another (ugly) solution would be to do a system call to retrieve this
value :
String[] cmd = {"cmd", "/c", "echo", "%USERPROFILE%"};
Process p = Runtime.getRuntime().exec(cmd, null);
...
> I don't think there's much that we can do about this - the only
> alternative really would be to define the home directory to be
> the value of Java's user.home system property, but that would be
> a java-centric solution to a java bug, and I'm certainly not
> advocating it.
>
> Is it worth noting this issue (and perhaps providing a snippet of
> java boilerplate for how to locate the home directory) in the
> Standard Profile section of the document, or would that be cluttering
> it too much with language-dependent details?
Maybe we could briefly note the issue and give a link to a detailed
explanation and possible remedy ?
Cheers,
Thomas
More information about the apps-samp
mailing list