I am trying to find the best way to grammatically determine if my program is running on Jboss 5 or Jboss 7 (eap-6.1). The paths I have found so far are jboss 5 or jboss 7, which do not work, because the code should work in both. I tried both solutions from here: How to get the version programmatically in JBoss AS 5.1? and they didn’t work. One of them complained about org.jboss.Main, which did not exist in jboss 7, the other complained that it did not end with "jmx / rmi / RMIAdaptor".
The only way I can see is to get Class.forName to look for "org.jboss.Version" (should be found if jboss 5), and if that fails, run Class.forName "org.jboss.util.xml. catalog.Version "(jboss 7). But that seems like a terrible idea.
The reason I need to know if the war works on jboss 5 or 7 is because there are some user files that are in different places in both. So "if jboss 5, execute this piece of code if jboss 7 executes another.
source
share