0

I need to create a properties file to store username/passwords for DBs and other websites for my application.

Is there a good place to put this?

I was thinking of putting in /usr/local/myapp/myapp.properties

However...this doesnt really make much sense for Windows boxes. However, I don't want to store it under a particular user's account as I want it to be global for all users.

Any thoughts?

DD.
  • 21,498
  • 52
  • 157
  • 246
  • Add it anywhere you feel like so (according to windows folder policies) and set a system environment variable so you can find it through it. – Alfabravo Jan 23 '12 at 22:57

3 Answers3

2

Store it wherever you like, and point your application to it via a vm parameter: -Dproperties.location=/usr/local/...

Then you can read it with System.getProperty("properties.location")

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • adding spring to the picture makes the question a bit different. You can ask a new one, I guess – Bozho Jan 24 '12 at 06:36
0

I have written on this property framework for the last year. It will provide of multiple ways to load properties, and have them strongly typed as well. Which also include a way to encrypt/decrypt a password property.

Have a look at http://sourceforge.net/projects/jhpropertiestyp/

JHPropertiesTyped will give the developer strongly typed properties. Easy to integrate in existing projects. Handled by a large series for property types. Gives the ability to one-line initialize properties via property IO implementations. Gives the developer the ability to create own property types and property io's. Web demo is also available, screenshots shown above. Also have a standard implementation for a web front end to manage properties, if you choose to use it.

Complete documentation, tutorial, javadoc, faq etc is a available on the project webpage.

FrederikH
  • 139
  • 2
  • 7
0

If you use the built-in Preferences class, the values will be automatically saved in the appropriate place on the user's system.

Edit:

Oops, I missed the "global to all users" requirement. This will not work on all systems in that case.

Russell Zahniser
  • 16,188
  • 39
  • 30