Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4642629
Votes 25
Synopsis Reopen RFE: 4199068 - Bring back getenv, consider setenv
Category java:classes_lang
Reported Against 1.4
Release Fixed
State 11-Closed, duplicate of 4173528, request for enhancement
Priority: 4-Low
Related Bugs 4173528 , 4738465
Submit Date 25-FEB-2002
Description




FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
 customer  Windows 2000 [Version 5.00.2195]

ADDITIONAL OPERATING SYSTEMS :
all other operating systems too.


A DESCRIPTION OF THE PROBLEM :

This is a request to reconsider the evaluation for Bug ID: 4199068
and to also consider a setenv method.

I would like the getEnv to be brought back with a new
setEnv.  For example on windows you would have to
setEnv(USERNAME, value)
on Unix
setEnv(USER, value)


Bug 4199068 was closed as will not fix, but due to the number of votes
placed on this rfe, and the number of comments that have been placed
on this bug, please reevaluate.

Here are reasons to reconsider:

There are a number of ways to make a program non-portable in java if I really wanted to already.  In 1.4 I could access a specific part of the windows registry making my program non-portable.  I believe it is the developers issue to make sure his program is portable.  There are some programs developers want to write without the intention of being portable(ie. we plan on using the windows registry to have an applet launch a windows application).  You are taking away from choice that
developers should be given.
thankyou in advance for your reconsideration, and I hope Sun can think about this a little more before deciding to keep it out.

one more thing, people are making their programs non-portable now because they are accessing environment variables by executing the respective commands using exec instead.  Instead of

setenv("NEW_ENV", <some value>)

but instead they are doing this
if(OS==windows)
    exec("set NEW_ENV="+<some value>);
if(OS==flavor of UNIX)
    exec("NEW_ENV="+<some value>);

People still create non-portable code, they just create uglier non-portable code.
thanks

Please visit the Bug Parade here to view the other comments on this:
http://developer.java.sun.com/developer/bugParade/bugs/4199068.html

(Review ID: 139305) 
======================================================================
Work Around
N/A
Evaluation
I think this is entirely appropriate (and long overdue).

  xxxxx@xxxxx   2002-12-09
Comments
  
  Include a link with my name & email   

Submitted On 17-MAY-2002
s_ananth
This is a really nice must have feature. I don't think this 
is very difficult to implement inside java. Consider 
applications that donot use the JNI but needs environment 
variables. Just for reading if we start using the JNI, the 
applications will sleep in the beginning. Please consider 
this RFE


Submitted On 13-MAR-2003
walterstroebel
(name and email suppressed, I'm getting enough SPAM already)

Obviously getenv is a completely portable system feature
with equivalences in every language and OS (I'm aware of the
MACOS issue but I'm convinced there is something else that
fullfills the same function).
The environment as passed to the JAVA VM should therefore be
accessible in the language. I personally do not care if this
is through System.getProperty("env.var") or System.getEnv
("var").

Setenv is a harder proposition and quite often useless as a
program's environment is merely a copy of the parent's. The
only sensible approach is the current one: pass a child's
environment along with Runtime.exec().

Btw: Supporting the environment in exec() but not in System
means one cannot exec() JAVA applications in a system
compliant manner...



Submitted On 10-APR-2003
mabdellateef
In large projects we rely on locating files relative to a root 
point, if this is hardcoded or set as an absolute path, the 
application won't be portable. We need the getEnv, setEnv 
back as we do benefit from using them a lot.
I can simply see Java relying on CLASSPATH variable for 
launching an application, why do I have to work otherwise in 
my own projects.
Thanks for considering access to these methods back.


Submitted On 28-APR-2003
stevel56
This is such an obvious feature to have its ridiculous.  Why 
can't this just be re-implemented?


Submitted On 29-APR-2003
mthome
getenv-like functionality is clearly completely portable -
most OSes have features which directly support the most
common interpretation.  Those OSes which do not, generally
lack such a feature completely.  Previous arguments against
support of getenv have focused on the lack of standard of
*content*, rather than the lack of standard API - this is,
IMO, not java's problem.  Attacking it anyway has slowed
acceptance of java as a language due to it's lack of
integration with nearly universal OS features and has forced
developers to work around it by using hacks (wrapper
scripts? ugh!  calling exec!?!? Ack!) that are FAR less
portable and unmaintainable than undeprecated getenv could
ever be. 
That said, I would actually prefer integrating getenv
functionality into one of the other facilities - e.g.
System.getProperty("myprop") or perhaps the Preferences API.


Submitted On 17-JUN-2003
andrew.webb@med.ge.com
I support having System.getenv()
 do what its documentation says it does:  

Gets an environment variable.
Returns the value of the variable, or null if the variable is not 
defined.

Yes, programmers should be advised that there is a Java 
standard way to get some system properties via 
System.getProperty(), but no, they should not be prevented 
from getting infomation from the system in a very established 
way. 

I don't want to resort to some OS dependent method to work 
around the removal of these function.

This is one of the very few areas in which I have to say that 
the C/C++ library support is better than Java.  

If you deny this request for enhancement, then at least make 
the documentation match the reality, and describe the 
function accurately.






Submitted On 04-JUL-2003
jabusia
The state above is wrong! It should rather be "Closed, 
duplicate of 4199068"! All interested in bringing "getenv" back, 
please move your votes to 4199068!



PLEASE NOTE: JDK6 is formerly known as Project Mustang