Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Java application server name and version

Tags:

java

servlets

web

I am writing a Web application with Java, and this WAR application may be deployed to different application servers, such as Tomcat/JBoss/Jetty/Weblogic.

For diagnostic purpose, I'd like to implement a dynamic web page to collect various environment/system information so that customer can provide these information to support engineers for diagnostics.

One piece of information that is useful is the application server name and version that this application gets deployed to, such as Tomcat 7.0, JBoss 5.1.0, Glassfish 3.0, etc.

I just wonder if there is any standard way to retrieve application server's name and version from different JEE application servers.

like image 321
nybon Avatar asked Sep 16 '11 05:09

nybon


People also ask

How do I find my Java server name?

In Java, you can use InetAddress. getLocalHost() to get the Ip Address of the current Server running the Java app and InetAddress. getHostName() to get Hostname of the current Server name.

Where is WebSphere application server name?

Click Servers > Server Types > WebSphere application servers . Click the server name to open it. The default server name is server1 . Under Server Infrastructure, click Java and Process Management > Process definition.

What is Java application server?

An application server is a Java™ Virtual Machine (JVM) that runs user applications. The application server collaborates with the web server to return a dynamic, customized response to a client request.


2 Answers

I have find some code for getting server information of where you deploy your application.
This code is written in Servlet to get server info in which it is running..

String str1 = getServletContext().getServerInfo();

By this you will get the server name and the server's version info.

I think it will some what help you..

like image 165
Yagnesh Agola Avatar answered Sep 21 '22 21:09

Yagnesh Agola


I don't think there is an easy way to do this, but I know you can identify tomcat from checking the System environment properties

 -- listing properties --  java.util.logging.config.file=/home/willie/.netbeans/7.0/apache-tom...  user.dir=/home/willie/apache-tomcat-7.0.14/bin  java.runtime.version=1.6.0_26-b03  java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment  java.endorsed.dirs=/home/willie/apache-tomcat-7.0.14/end...  os.arch=amd64  java.io.tmpdir=/home/willie/.netbeans/7.0/apache-tom...  java.naming.factory.url.pkgs=org.apache.naming  os.name=Linux  sun.jnu.encoding=UTF-8  java.library.path=/usr/lib/jvm/java-6-sun-1.6.0.26/jre/...  tomcat.util.scan.DefaultJarScanner.jarsToSkip=bootstrap.jar,commons-daemon.jar,tomc...  java.specification.name=Java Platform API Specification  java.class.version=50.0  sun.management.compiler=HotSpot 64-Bit Tiered Compilers  os.version=2.6.38-8-generic  user.home=/home/willie  user.timezone=Africa/Johannesburg  catalina.useNaming=true  java.awt.printerjob=sun.print.PSPrinterJob  java.specification.version=1.6  file.encoding=UTF-8  catalina.home=/home/willie/apache-tomcat-7.0.14  user.name=willie  java.class.path=/home/willie/apache-tomcat-7.0.14/bin...  java.naming.factory.initial=org.apache.naming.java.javaURLContext...  sun.security.krb5.debug=false  package.definition=sun.,java.,org.apache.catalina.,org.a...  java.vm.specification.version=1.0  sun.arch.data.model=64  java.home=/usr/lib/jvm/java-6-sun-1.6.0.26/jre  sun.java.command=org.apache.catalina.startup.Bootstrap...  catalina.base=/home/willie/.netbeans/7.0/apache-tom...  file.separator=/  java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...  common.loader=${catalina.base}/lib,${catalina.base}.. 

you can check for tomcat/jetty/jboss... specific entries and determine the version and server by that means

like image 28
epoch Avatar answered Sep 21 '22 21:09

epoch