SAMP on Windows

Mark Taylor m.b.taylor at bristol.ac.uk
Wed May 14 02:11:35 PDT 2008


On Wed, 14 May 2008, Mark Taylor wrote:

> excellent - USERPROFILE sounds like exactly what we need then. It should be 
> easy to implement like that, without requiring too
> much system-dependent code, in any sensible language.

Having said that: I note for reference here that there is an issue 
with implementing this in java.  This is related to java bug 4787931:

    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4787931

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.

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?

Mark

-- 
Mark Taylor   Astronomical Programmer   Physics, Bristol University, UK
m.b.taylor at bris.ac.uk +44-117-928-8776 http://www.star.bris.ac.uk/~mbt/



More information about the apps-samp mailing list