To getenv or not getenv  
Author Message
lordy





PostPosted: 2006-7-29 2:31:00 Top

java-programmer, To getenv or not getenv I'm using 1.4.2 for some commecial development. I was just about to set
a property and pass it on the command line when I noticed that System.getenv is
not deprecated in 1.5.0. So is it bad form to use a deprecated 'getenv'
in 1.4.2 given its new lease of life in 1.5.0??

Being 'allowed' to use getenv would make certain parts of the program
more expressive.

Cheers,
Lordy

 
Roland de Ruiter





PostPosted: 2006-7-29 3:42:00 Top

java-programmer >> To getenv or not getenv On 28-7-2006 20:31, lordy wrote:
> I'm using 1.4.2 for some commecial development. I was just about to set
> a property and pass it on the command line when I noticed that System.getenv is
> not deprecated in 1.5.0. So is it bad form to use a deprecated 'getenv'
> in 1.4.2 given its new lease of life in 1.5.0??
>
> Being 'allowed' to use getenv would make certain parts of the program
> more expressive.
>
> Cheers,
> Lordy
>
There's no point in using it on 1.4.2, since System.getenv(String)
always throws an error when try to run it on a 1.4.2 JRE.

Compare output of the following program:
public class ToGetenvOrNotToGetenv
{
public static void main(String[] args)
{
System.out.println("java.runtime.version="
+ System.getProperty("java.runtime.version"));
System.out.println("PATH=" + System.getenv("PATH"));
}
}


On JRE 1.4.2:
java.runtime.version=1.4.2_12-b03
java.lang.Error: getenv no longer supported, use properties and
-D instead: PATH
at java.lang.System.getenv(System.java:691)
[...]

On JRE 1.5.0:
java.runtime.version=1.5.0_07-b03
PATH=C:\Data\bin\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;[...]
--
Regards,

Roland
 
lordy





PostPosted: 2006-7-29 3:49:00 Top

java-programmer >> To getenv or not getenv On 2006-07-28, Roland de Ruiter <email***@***.com> wrote:
> On 28-7-2006 20:31, lordy wrote:
>> I'm using 1.4.2 for some commecial development. I was just about to set
>> a property and pass it on the command line when I noticed that System.getenv is
>> not deprecated in 1.5.0. So is it bad form to use a deprecated 'getenv'
>> in 1.4.2 given its new lease of life in 1.5.0??
>>
>> Being 'allowed' to use getenv would make certain parts of the program
>> more expressive.
>>
>> Cheers,
>> Lordy
>>
> There's no point in using it on 1.4.2, since System.getenv(String)
> always throws an error when try to run it on a 1.4.2 JRE.

Cheers,

Slightly more than deprecated then !

Lordy