Obtain the $JBOSS_HOME/bin value in JBoss 4.2.x
Calling the JBoss command line tool Twiddle, located in $JBOSS_HOME\bin directory, can give us the port number on wh开发者_JS百科ich 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
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");
精彩评论