The simplest thing I can think of is to check the properties of the system at runtime, since both servers will almost certainly determine their own. For example, JBoss 4 defines the system property jboss.server.dir . Check if this property exists, and if so, then you can assume that you are working under this server. OC4J will have something similar.
Alternatively, try reflecting the loading of a class that is part of the server infrastructure (e.g. org.jboss.Version in JBoss 4). If it exists, you know which server you are on.
source share