For checking Java version
# java -version
==============output==================
java version “1.6.0_29″
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode)
=========================================
For Tomcat
Execute the script
[~]# sh /usr/local/jakarta/tomcat/bin/version.sh
==============output==================
Using CATALINA_BASE: /usr/local/jakarta/tomcat
Using CATALINA_HOME: /usr/local/jakarta/tomcat
Using CATALINA_TMPDIR: /usr/local/jakarta/tomcat/temp
Using JRE_HOME: /usr/local/jdk
Using CLASSPATH: /usr/local/jakarta/tomcat/bin/bootstrap.jar:/usr/local/jakarta/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.32
Server built: Oct 3 2012 08:51:20
Server number: 7.0.32.0
OS Name: Linux
OS Version: 2.6.18-028stab070.5-PAE
Architecture: i386
JVM Version: 1.6.0_29-b11
JVM Vendor: Sun Microsystems Inc.
==========================================