How to get Tomcat version number in Java -
this question has answer here:
- how find out running tomcat version 18 answers
how tomcat/catalina version number in java?
i've seen lots of how via command line etc. that's not code can use, cannot use catalina.path version number has been stripped path.
please note want use version in code, various jsp solutions i've looked @ not work me.
thanks
from jsp
in jsp file can print out version this:
tomcat version : <%= application.getserverinfo() %>
output:
tomcat version : apache tomcat/8.0.14
outside of jsp (any java code)
if want outside of jsp (e.g. in servlet or listener or w/e) take @ org.apache.catalina.util.serverinfo
class, has nice static methods:
system.out.println(serverinfo.getserverbuilt()); system.out.println(serverinfo.getserverinfo()); system.out.println(serverinfo.getservernumber());
output:
sep 24 2014 09:01:51 apache tomcat/8.0.14 8.0.14.0
so want serverinfo.getservernumber()
.
note:
the serverinfo
class has main()
method can run standalone application too:
java -cp lib/catalina.jar org.apache.catalina.util.serverinfo
example output:
server version: apache tomcat/8.0.14 server built: sep 24 2014 09:01:51 server number: 8.0.14.0 os name: windows 7 os version: 6.1 architecture: x86 jvm version: 1.7.0_55-b13 jvm vendor: oracle corporation
Comments
Post a Comment