Honestly, I am a little embarrassed that I did not know this.
However, here is the problem statement.
Use properties defined in the Jboss configuration file ( standalone.xml or domain.xml) in Java.
The properties are defined in the config file as such ( standalone.xml in my case)
<system-properties> <property name="APP-NAME" value="MyApp"/> <property name="LOG_DIR" value="C:/Logs"/> </system-properties>
We are all we aware of the fact that properties are defined in an properties file and we can use it in our Java code (in case if you need help with it, please check this post) but to read the properties defined in Jboss config, we will have to do something like this.
String logDir = System.getProperty("LOG_DIR");
String appName = System.getProperty("APP-NAME");
And that’s it. Pretty simple and straight forward.
Now, if for any reason, you have to append properties, do this.
Example: The logs should remain in C:/Logs/MyApp, so apparently, I have append the properties with a “/”. But now the problem is basing on the OS, this separator might differ. In such situations, File.separator comes to rescue as shown below.
String logDir = System.getProperty("LOG_DIR");
String appName = System.getProperty("APP-NAME");
String log = logDir+File.separator+appName
Hope this helps.
