• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Reading ENVIRONMENT varibale in the JAVA program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there ,
Here I have got very tricky problem.Most of you might not find it very tricky...but surely it is for me.
Well let me get to the problem.
I have a environment variable (on windows NT 4.0) by name SERVER_HOME(it is the installation dir for server).My requirment is to read that variable inside the java program(to know the server installation dir).
I tried to read it by getting the system properties.But the environment variable(SERVER_HOME) doesn't appear as system properties.
I even tried it by using the echo command(DOS command) using the Runtime.exec() method.But somehow the echo command doesn't seem to run thru the java program.
Can someone guide me how do i do this?
I am using java1.2.2
OS windows NT 4.0
Thanks in advance
Shashi
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen this done before writing the os property to the JVM property using the command line (it looks like this
java -DSERVER_HOME=%SERVER_HOME% package.Class
If you put it in a batch file it should work nicely.
Dave.
 
shashi sonawane
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what if it is the servlet which want to read the same parameter?

Originally posted by David O'Meara:
I've seen this done before writing the os property to the JVM property using the command line (it looks like this
java -DSERVER_HOME=%SERVER_HOME% package.Class
If you put it in a batch file it should work nicely.
Dave.


 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlets have their own version of ENVIRONMENT variables, which you can specify in web.xml.

check out this thread: http://www.javaranch.com/ubb/Forum7/HTML/000638.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic