Hi, I would like to know if you could permanently set a System property. Like user.home or add a new one? I think you can, but I forgot which file to modify...? Thanks in advance. Yoo-Jin. [This message has been edited by Yoo-Jin Lee (edited January 07, 2001).]
Sajan Joseph
Ranch Hand
Joined: Jan 05, 2001
Posts: 40
posted
0
Originally posted by Yoo-Jin Lee: Hi, I would like to know if you could permanently set a System property. Like user.home or add a new one? I think you can, but I forgot which file to modify...? Thanks in advance. Yoo-Jin. [This message has been edited by Yoo-Jin Lee (edited January 07, 2001).]
Hi Lee, I guess the file you have to modify is System.Properties. You can get the Properties associated with the system using System.getProperty(). If you want to set any property you can use System.setProperty()--> added by Java 2. There are several system properties available like java.version -- Java Runtime Environment version java.vendor -- Java Runtime Environment vendor java.vendor.url -- Java vendor URL java.home -- Java installation directory etc. Refer the Java documentation for further details. SJ
Yoo-Jin Lee
Ranch Hand
Joined: Nov 01, 2000
Posts: 119
posted
0
Hi Sajan, Thanks for your reply, What I wanted to know though is where the actual file resides. Because System.setProperty(..) is not persistent. ie. public class Changer { public void main(String [] args){ System.setProperty("user.home", "c:\\Temp"); } } public class Reader{ public void main(String [] args){ System.getProperty("user.home"); } } Invoking Changer then Reader would produce whatever the current directory is ie: c:\Area51 and not c:\Temp. I would like to modify the actual file permanently if possible or add my own name/value ie. user.path = c:\temp. cheers, Yoo-Jin.
Peter Tran
Bartender
Joined: Jan 02, 2001
Posts: 783
posted
0
Yoo-Jin, When you invoke the JVM, trying adding the -D option. E.g. java -Duser.home=c:\\temp Reader -Peter
Yoo-Jin Lee
Ranch Hand
Joined: Nov 01, 2000
Posts: 119
posted
0
Peter, Thanks for your reply. I ended up doing that but I wish I could actually see the actual System file. cheers, Yoo-Jin.
Carl Trusiak
Sheriff
Joined: Jun 13, 2000
Posts: 3340
posted
0
First of all, Properties is a java class that is used to hold properties that maybe needed for your program. The basic properties that you are talking about are provided by the operating system. Not all of these can be changed. If you try, you will get a SecutrityException (You can't change the os.name for instance). The basic properties are read from the memory of the computer (basically) you can add additional variables to this by setting environment variables in the operating system you are using. Such as in Win95 you can add to the autoexec.bat the line: set BARTENDER_NAME=Carl This line can go in any batch file and BARTENDER_NAME will equal Carl until you reset it. In your java program If you add the line System.out.println(System.getProperty("BARTEDER_NAME")); You'll get Carl as the output. In the bash shell on Linux or Unix you'd use BARTENDER_NAME=Carl export BARTENDER_NAME You can create your own set of properties for your java program and store them in a file and load them using the Properties load() method. Hope this helps