Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Linux - Obtain environment variables

Thread view: 
pd - 13 Jun 2007 06:26 GMT
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.
stefanomnn - 13 Jun 2007 06:50 GMT
> guys,
>
[quoted text clipped - 7 lines]
> 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?
Gordon Beaton - 13 Jun 2007 06:56 GMT
> under linux, how can java access environment variables. currently i
> have something like,
[quoted text clipped - 4 lines]
>
> 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

--
stefanomnn - 16 Jun 2007 12:32 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.