| Author |
Properties file
|
Leslie Chaim
Ranch Hand
Joined: May 22, 2002
Posts: 336
|
|
|
Is there any specific switch to pass a Properties file from the command line?
|
Normal is in the eye of the beholder
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
None that I can see. http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html#options
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Jeroen Wenting
Ranch Hand
Joined: Oct 12, 2000
Posts: 5093
|
|
nope. You need to parse the commandline yourself and determine which is the properties file. Or more likely you will force a specific name and location on the file and read it from there. Or have another properties file at a specific name and location and read the name and location of the properties file from there
|
42
|
 |
Leslie Chaim
Ranch Hand
Joined: May 22, 2002
Posts: 336
|
|
|
I guess I was looking for something of the Properties class in conjunction with the -D switch... Rather then saying arg1=value1 arg2=value2 ... to pass a file.
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
|
If you pass the pathname to the file into the main method, you can create from that String a FileInputStream which can then be loaded into a Properties object.
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
You could also use the -D option in conjunction with some new system property - e.g. java -Dleslies.properties.file=foo/bar/config.properties MyClass Then use that system property to load the Properties:
|
"I'm not back." - Bill Harding, Twister
|
 |
Leslie Chaim
Ranch Hand
Joined: May 22, 2002
Posts: 336
|
|
What a KISS rule! Thanks JRY I think the Properties file should not be part of cmd-line-args-validation and your solution is a compromise.
|
 |
 |
|
|
subject: Properties file
|
|
|