• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Configuration files - Best Practice?

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have several stand-alone (no web container) java programs that I want to run on multiple systems (Unix, Windows, test, production environments). There are several configuration parameters that I need to keep out of the jar for easy modification.

What's the best way to do this?

Some options I've considered are:
1) Using a straight properties file and passing the full path name of this file as a command line option. (Works but was hoping for a better way.)

2) Using a properties file and access it through a resource bundle.
(Not working for me. I have to run the app as a jar and can't seem to have the app find the resource outside the jar, no matter what classpath settings I use.)

3) Using Spring framework and an XML config file. (Essentially the same as 1 and 2, you still have to tell spring where to find the config file.)

4) System enviroment variables. (Haven't tried this yet.)

5) other ideas?

Thanks in advance for your input.
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
don't use system variables (java is meant to be plattform independent, unix or windows systems often use different system-var identifiers, pathseperators etc.).

java properties is the right way.
but best thing for CM (configuration management) matters with java is definetely Ant! Ant is using property-files, too.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, Properties file is what i would also use.

Also, XML file and parse the file for values is a nice option too....

Since you have support for resource bundle in J2SE itself, you do not have to have to depend on Xerces or Springs. Go for properties file

Also, some way or other you have to tell your program where to find the config info/Dynamic Values. All you can abstract is the value for Configuration Variables.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic