By Martin Cabrera

We have had this issue several times, which is why we are sharing tips with the JBoss community, particularity JBoss Application Server (AS) developers.


I have a scenario to access certain key values from a config file. I need Access to this properties file from a Java application (WAR or JAR) deployed in a JBoss AS


1- Hard Code the path (no please !!)

Hard Code the path and create a Properties instance.

2- Using JBoss System Properties (almost)

Avoid to Hard Code … use a tool from JBoss. System.getProperty()

JBoss allows access to a standard set of properties. For instance: jboss home dir (“jboss.server.home.dir). Here I share some piece of code to make an instance of this properties file.

3- Using Resource bundle (the best !)

JBoss AS add to the classpath a lot of folders and jars. One of them is the “config” folder into the server domain. eg. “server/default/conf”

ResourceBundle objects contain an array of key-value pairs. You specify the key, which must be a String, when you want to retrieve the value from the ResourceBundle. The value is the locale-specific object.

When you create a ResourceBundle this properties file must be in the classpath.

Then we could:

In this example the file “” must be inside a “project” folder declared in the classpath, for instance: “config”

That’s all folk !