Saturday, March 26, 2011

JBoss and property files

I needed to use Java Properties in JBoss and found it somewhat difficult to find any decent documentation or examples how to do this, so here's how I got it working. It might not be the correct way, but it works.

Create your .properties file (key/value pairs) and place it in for example the WEB-INF dir. Load the props as follows:

Properties props = new Properties();
props.load(application.getResourceAsStream("/WEB-INF/mypropertiesfile.properties"));

Then load whatever you need.

No comments:

Post a Comment