Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Linux - Obtain environment variables

Reply
Thread Tools

Linux - Obtain environment variables

 
 
pd
Guest
Posts: n/a
 
      06-13-2007
guys,

under linux, how can java access environment variables. currently i
have something like,
Properties envVars = new Properties();
Runtime r = Runtime.getRuntim();
Process p = null;
p = r.exec("env");

and this doesnt work. does anybody know how to get this to work.
thanks a lot.

 
Reply With Quote
 
 
 
 
stefanomnn
Guest
Posts: n/a
 
      06-13-2007
On 13 Giu, 07:26, pd <(E-Mail Removed)> wrote:
> guys,
>
> under linux, how can java access environment variables. currently i
> have something like,
> Properties envVars = new Properties();
> Runtime r = Runtime.getRuntim();
> Process p = null;
> p = r.exec("env");
>
> and this doesnt work. does anybody know how to get this to work.
> thanks a lot.


Hello!
Did you try taking input stream from process?

 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      06-13-2007
On Tue, 12 Jun 2007 22:26:47 -0700, pd wrote:
> under linux, how can java access environment variables. currently i
> have something like,
> Properties envVars = new Properties();
> Runtime r = Runtime.getRuntim();
> Process p = null;
> p = r.exec("env");
>
> and this doesnt work. does anybody know how to get this to work.


"Something like" doesn't help anyone debug your real code.

Try using Properties.load(InputStream), passing the p.getInputStream()
as the argument.

If that doesn't work, post a complete example.

/gordon

--
 
Reply With Quote
 
stefanomnn
Guest
Posts: n/a
 
      06-16-2007
if you run on java 1.5,
you needn't use Process class,
toy can use System.getEnvs() method,
which return you a map of all environnement settings

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo perl script with environment variables on linux powah Perl Misc 7 04-23-2009 02:00 AM
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
70-284 Lab Environment, Need Virtual Environment brooklynbridge508@hotmail.com MCSA 4 05-02-2007 09:49 AM
Setting an environment variable from another environment variable marcwentink@hotmail.com Java 5 04-04-2007 10:39 PM
problem with setting Java environment variables in Linux Leo Java 2 03-21-2006 04:49 PM



Advertisments