The road so far….

November 22, 2010

Mixed approach of loading java.util.Properties using Spring

Filed under: java — Tags: — Rahul Sharma @ 8:05 pm

Last week  I was attending a training where we were developing  a command line application. The application had  few static properties that were stored in a properties file and few of them where supposed to be generated when the application would start.  The application was using Spring, so loading the Properties file was a simple use case of using PropertiesPlaceholderConfigurer but the complication came from, how to load the properties  that were generated when the application started ? (more…)

Advertisements

November 12, 2010

Use java.util.prefs.Preferences instead of java.util.Properties

Filed under: java — Tags: , — Rahul Sharma @ 10:07 pm

A typical installer for an application needs to ask the user a couple of options and some of these are configuration questions e.g. the port on which the application should run, how it should run etc. The application has to remember these options and use them in every run. Standard manner of solving such a problem is to write these options in a properties file which can be loaded at the start-up of the application. But then again the problem shifts to some other area i.e.  remember the install path and then load the required properties file from the installed path.

Remembering installed path can be solved by setting an environment variable e.g. MYAPP_HOME. The variable can be initialized with the required value  while installing  so that every time the application gets loaded the variable will be set. This is a typical solution that is employed in most of the projects. (more…)