Forums Register Login

windows environmentvariable in a property-file

+Pie Number of slices to send: Send
Hi,

I would like to use a windows environmentvariable in a property-file, like this:

In windows I create a variable:


In my propertyfile, I put something like this:

Can anyone tell me if this is possible? I know, it's not possible like this, but maybe it is in another way? I don't want to use any javacode for this, just the property-file.

Thanks!
Regards, Bianca
+Pie Number of slices to send: Send
Bianca,

I don't know what you mean when you say you don't want to use any java code for this, as I don't see the value of Java properties files without Java.

Anyway, I think it isn't necessary to do what you describe. You already have direct access to the environment variables from the java.lang.System class, using its static getenv method.

You can store the names of the environment vars in your resource bundle(s), and retrieve the values at runtime with getenv. This approach should be portable to any system that uses environment variables (Windows, UNIX, Linux, Mac...)

Does this meet your requirements?
[ February 08, 2007: Message edited by: Philip Shanks ]
+Pie Number of slices to send: Send
Philip,

Unfortunately getenv is depricated in the version of Java we use. Besides that, I have to use Java code to do this, and that's not what I'm looking for.

The reason that I cannot use Java code for this, is that I'm not allowed to change the code we already have. I am allowed however to change the property-file. In this property-file, I want to make the drive where the reports should go, dynamic.

I'm afraid this is not possible, but maybe someone has a good idea.

Bianca
+Pie Number of slices to send: Send
Bianca,

Okay, now I understand your situation. I don't know of a way to do what you require, but there are many creative minds in these forums! Consider asking the moderator(s) to move this to the Advanced Java forum.

I once wanted to do something similar. I had a notion to duplicate the syntax that you sometimes see in config files: my.property=${some.other.property}/foo
Unfortunately, it appeared that I would have to roll my own Properties implementation to do it and there was no time for that.

Just curious, are you using J2SE 1.4? I see that getenv is indeed deprecated there. I looked at both the 1.5 and 1.6 API's and the method appears to be intact in each. I never noticed that in an *earlier* version the same method is deprecated. Looks like someone changed their mind!
+Pie Number of slices to send: Send
Philip,

We're indeed using 1.4
For what I heard, they deprecated it because it was not applicable for all operating systems. But I'm not sure why it's no longer deprecated.

Bianca
His brain is the size of a cherry pit! About the size of this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 881 times.
Similar Threads
How can I check the existence of a dir?
Variables/properties used in property files
Different character sets on Unix/Windows? Whats happening?
Spring Property reading
How to use the Ant Property file setting?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:14:43.