• Post Reply Bookmark Topic Watch Topic
  • New Topic

windows environmentvariable in a property-file  RSS feed

 
Bianca Hagen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Philip Shanks
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bianca Hagen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Philip Shanks
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Bianca Hagen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!