aspose file tools
The moose likes Java in General and the fly likes Reading ENVIRONMENT varibale in the JAVA program Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Reading ENVIRONMENT varibale in the JAVA program" Watch "Reading ENVIRONMENT varibale in the JAVA program" New topic
Author

Reading ENVIRONMENT varibale in the JAVA program

shashi sonawane
Greenhorn

Joined: Jun 12, 2001
Posts: 2
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
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Jun 12, 2001
Posts: 2
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.

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading ENVIRONMENT varibale in the JAVA program
 
Similar Threads
Remote Debugging the Oracle Weblogic 10.3.3
startup.bat stops itself
java, java.io.File and OS path variables
new domain with weblogic6.1 problem?
Setting up the Java Web Services tutorial and Sun Java system appn server