How to read environment variables in Java.

Tim Panton - Westhawk Ltd tpanton at ibm.net
Sat Nov 12 19:29:10 PST 2005


Ah, but he also added that he wanted
to find a propreties file, which is hardly
a windows only concept.
The nice thing about (the other)Tim's 
solution is that it keeps the non-portable bit 
out of the java an puts it in the
startup script, which is different
for every platform.

For components (servets,com etc)
I generally put the properties file
in the classpath, and use Class.getResource.... To read it.

T.


"Joe Sam Shirah" <jshirah at ibm.net> wrote:
__________
>
>    Hi Tim,
>
>    You are corrrect, free of any other context.  However, the man's
>question, which I repeated, was:
>
>>> I need the fully qualified
>>> path to the Winnt\system32 directory.
>
>and originally referred to %WINDIR%.  Since one can also determine the OS as
>a system property and, presumably, %WINDIR% has little to no meaning outside
>of Windows machines, this should be acceptable in the context here.
>
>    The questioner had also said earlier that he could not used the method
>you propose, which had also been sent by earlier responders.
>
>    Last, I would say that one can do system dependent things so long as
>they don't affect portability.  That's what system and other properties are
>for.
>
>
>Joe Sam Shirah
>Autumn Software
>Consulting/Development/Outsourcing
>Please Note New Email:  jshirah at attglobal.net
>___________________________________________
>
>-----Original Message-----
>From: Tim O'Neil <tim at encommerce.com>
>To: advanced-java at xcf.berkeley.edu <advanced-java at xcf.berkeley.edu>
>Date: Thursday, February 03, 2000 9:32 PM
>Subject: Re: How to read environment variables in Java.
>
>
>>At 09:00 PM 2/3/00 -0500, you wrote:
>>
>>>     Hi Ed,
>>>
>>>     Under 1.2.2 on NT, the system property "user.home" on my machine
>shows:
>>>
>>>user.home=C:\WINNT\Profiles\myprofilename
>>>
>>>     In addition, "java.library.path" includes
>>>
>>>java.library.path=C:\WINNT\System32;
>>>
>>>
>>>     You don't get to actually read the environment variable, but seems
>like
>>>working with one or another of these would do for your needs if you're on
>>>the version.
>>
>>
>>This is system dependant, so you don't get to do it. What one can do is
>>write a script (or batch file) to load the variables in at start up though.
>>
>>Something like this as the calling line in your script:
>>
>>/opt/blah/doh/rae/me java -D$MY_VAR -D$YOUR_VAR -D$EVERYONES_VAR
>>myCoolClassHubbahHubbah
>>
>>
>>
>>-Tim
>>
>>
>
>
>
>---
>To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
>To get help, mail advanced-java-help at xcf.berkeley.edu
>
---
URL http://www.westhawk.co.uk/

---
To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
To get help, mail advanced-java-help at xcf.berkeley.edu



More information about the Advanced-java mailing list