tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim O'Neil <...@xythos.com>
Subject RE: Getting the user environment variable::Need help
Date Tue, 07 Aug 2001 15:43:14 GMT
That said, do this:

Properties props = System.getProperties();
props.put("MYVAR", "MYVALUE");
System.setProperties(props);

Then later on in your program you can get the value
to your hearts content. Or even in another class or
package.

Or use a wrapper to load shell variables. But if all
you want to do load your own defined variables use the
above code.

At 07:33 AM 8/7/2001, you wrote:
>1) This isn't a Tomcat question: if you'd done the same in a java
>application, you'd have found the same thing.  There are forums, newsgroups,
>and mailing lists for Java questions.
>
>2) You're confusing environment variables with properties.  Properties are
>defined either by loading them from a properties file, or by specifying them
>on java's command line (with "-D").
>
>3) There is a method, System.getenv(), to get environment variables, but
>it's deprecated (the whole concept of environment variables is incredibly
>OS-specific).  So you really _should_ be using properties, or
><context-param> elements defined in your application's web.xml.  Look at
>java.util.Properties for the former, and the servlet spec for the latter.
>
>                                         -- Bill K.
>
> > -----Original Message-----
> > From: Nilanjan Das [mailto:nilanjan@india.hp.com]
> > Sent: Tuesday, August 07, 2001 7:12 AM
> > To: tomcat jakarta
> > Subject: Getting the user environment variable::Need help
> >
> >
> > Hi,
> >
> > I am on HP-UX and trying to access one user environment varaible from
> > the Java code using
> > System.getProperty() method but it is returning NULL. Can anyone point
> > out why? This is what I did:
> >
> > $export TEST=testing
> > $echo $TEST
> > testing
> >
> > But when I execute System.getProperty("TEST") from my code, it returns
> > NULL.
> >
> > Can any of you help?
> >
> > Thanks,
> > Nilanjan
> >
> >


Mime
View raw message