tags:

views:

11

answers:

1

Calling the JBoss command line tool Twiddle, located in *$JBOSS_HOME\bin directory*, can give us the port number on which JBoss is listening for HTTP requests (see Q2366489). That's smashing :)

However, we can't rely on the fact that the system administrator has set the JBOSS_HOME path variable, and it would be useful to know if we can obtain this directory programatically from within the JBoss environment. In my case the project is deployed as a WAR file.

TIA

+1  A: 

This, and various other path-related values, are set by JBoss as system properties, which you should use to obtain them.

For example, the system property jboss.home.dir will be set to the equivalent of $JBOSS_HOME, regardless of how the server is actually started.

The various system properties are defined in org.jboss.system.server.ServerConfig.

So:

String jbossHomeDir = System.getProperty("jboss.home.dir");
skaffman
Well answered, thanks!
ian_scho