LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2002, 10:45 PM   #1
edreddy
Member
 
Registered: Jul 2002
Location: INDIA, Bangalore.
Distribution: Red Hat Enterprise Linux 3.0 Advanced Server
Posts: 34

Rep: Reputation: 15
how to get environmental variable from JAVA program


hey! guys
I have an application in java servlets, which uses one IP address. so, everytime i run it on different machine in my LAN, I have to replace the IP address in source code and recompile the entire appication. I don't want this mess.
so, all I need is just to declare one environmental variable in my application's configuration file and export that variable to all processes that starts from that point onwards(i.e.the point where my application starts.)
but I don't know how to get that envireonmental variable value into my program.(exactly what we have getenv() function in C).
so, help me in getting getenv() kind of stuff in JAVA.
very Urgentttttttt.................................please.

Last edited by edreddy; 07-28-2002 at 01:50 AM.
 
Old 07-29-2002, 07:42 AM   #2
sarin
Member
 
Registered: May 2001
Location: India, Kerala, Thrissur
Distribution: FC 7-10
Posts: 354
Blog Entries: 2

Rep: Reputation: 34
I don't know anything of java but I have seen my friend using System class to access env vars. I have seen him using System.getProperty to do that.
--Sarin
( He told me that it is in offical java tutorial -> essentials -> system )
 
Old 07-29-2002, 10:38 AM   #3
tda
Member
 
Registered: Mar 2002
Location: Ukraine, Kiev
Distribution: Mandrake 7.2
Posts: 37

Rep: Reputation: 15
Re: how to get environmental variable from JAVA program

Quote:
Originally posted by edreddy
hey! guys
I have an application in java servlets, which uses one IP address. so, everytime i run it on different machine in my LAN, I have to replace the IP address in source code and recompile the entire appication. I don't want this mess.
so, all I need is just to declare one environmental variable in my application's configuration file and export that variable to all processes that starts from that point onwards(i.e.the point where my application starts.)
but I don't know how to get that envireonmental variable value into my program.(exactly what we have getenv() function in C).
so, help me in getting getenv() kind of stuff in JAVA.
very Urgentttttttt.................................please.
In JDK before JDK 1.2 you was able use static method System.getenv(...) for access env varbls. But since JDK 1.2 you can't use this method because SUN decided that env vars are very system depended. This method is deprecated and throws exception. I can post java-code that can get access env variables on *NIX and Windows. But I think that you can pass IP-address as parameter to applet.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting an environmental variable maevious Linux - Newbie 6 11-24-2005 04:15 PM
Problem in installating vcdimager because of PKG_CONFIG_PATH environmental variable! koodoo Linux - Newbie 3 08-22-2005 08:44 PM
nohup tcsh (environmental variable) podollb Linux - Software 0 05-17-2004 05:44 PM
"How do i add an Environmental Variable in Redhat 8 ???? jmax24 Linux - Software 1 04-17-2004 12:30 AM
setting environmental variable cc to a working compiler blathen Linux - Newbie 2 10-27-2003 12:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration