You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by bachuba <ba...@yahoo.com> on 2007/06/07 17:26:26 UTC

Programmatically Determine JVM Version used by Tomcat

Hi,
I'm fairly new to using Tomcat, but need to determine what JVM version (or
at least the path to it) a running Tomcat service is currently using on a
Windows system.  If I run tomcat5w.exe and click on the Java tab, I notice
the informaiton is listed there, but I would like to be able to get at that
programmatically.  We are currently using Tomcat version 5.0.28.  Could
somone please describe how this could be done?  Thanks.
-- 
View this message in context: http://www.nabble.com/Programmatically-Determine-JVM-Version-used-by-Tomcat-tf3884522.html#a11010153
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Programmatically Determine JVM Version used by Tomcat

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
I copied this from the wildcat source at http://coolese.100free.com/


            sInfo += "OS Name: " + System.getProperty("os.name") + "\n";
            sInfo += "OS Version: " + System.getProperty("os.version") + 
"\n";
            sInfo += "Architecture: " + System.getProperty("os.arch") + 
"\n";
            sInfo += "JVM Version: " + 
System.getProperty("java.runtime.version") + "\n";
            sInfo += "JVM Vendor: " + System.getProperty("java.vm.vendor") + 
"\n";
            //Get the stuff Tomcat produces...
            sInfo += "Tomcat Server version: " + 
org.apache.catalina.util.ServerInfo.getServerInfo() + "\n";
            sInfo += "Tomcat Server built: " + 
org.apache.catalina.util.ServerInfo.getServerBuilt() + "\n";
            sInfo += "Tomcat Server number: " + 
org.apache.catalina.util.ServerInfo.getServerNumber() + "\n";

Everything you need.... enjoy

You do know that the bin.... holds a version.bat and you could also just run 
that.


----- Original Message ----- 
From: "bachuba" <ba...@yahoo.com>
To: <us...@tomcat.apache.org>
Sent: Thursday, June 07, 2007 5:26 PM
Subject: Programmatically Determine JVM Version used by Tomcat


>
> Hi,
> I'm fairly new to using Tomcat, but need to determine what JVM version (or
> at least the path to it) a running Tomcat service is currently using on a
> Windows system.  If I run tomcat5w.exe and click on the Java tab, I notice
> the informaiton is listed there, but I would like to be able to get at 
> that
> programmatically.  We are currently using Tomcat version 5.0.28.  Could
> somone please describe how this could be done?  Thanks.
> -- 
> View this message in context: 
> http://www.nabble.com/Programmatically-Determine-JVM-Version-used-by-Tomcat-tf3884522.html#a11010153
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Programmatically Determine JVM Version used by Tomcat

Posted by gb1071nx <gb...@globallyboundless.com>.
Can you make something out of this? 

public class JavaVer {
 public static void main(String[] args) {
   System.out.println("java.version: " +
System.getProperty("java.runtime.version"));
   System.out.println("JAVA_HOME: " + System.getProperty("JAVA_HOME"));
  }
}

D:\DEV\classes>java -version
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

D:\DEV\classes>java -DJAVA_HOME="c:\j2sdk1.4.2_10" JavaVer
java.version: 1.6.0_01-b06
JAVA_HOME: c:\j2sdk1.4.2_10


As you can see, "java.version" gives you what "running JVM is currently
using", regardless of what JAVA_HOME says (or any other env var), but
I'm not sure if this is totally borked in Windows Service-land.

You'd then have to compare the two strings to see if they're not equal.
Or if one equals something it shouldn't...


> -----Original Message-----
> From: David kerber [mailto:dckerber@verizon.net] 
> Sent: Thursday, June 07, 2007 10:31 AM
> To: Tomcat Users List
> Subject: Re: Programmatically Determine JVM Version used by Tomcat
> 
> bachuba wrote:
> > Hi,
> > I'm fairly new to using Tomcat, but need to determine what 
> JVM version 
> > (or at least the path to it) a running Tomcat service is currently 
> > using on a Windows system.  If I run tomcat5w.exe and click on the 
> > Java tab, I notice the informaiton is listed there, but I 
> would like 
> > to be able to get at that programmatically.  We are currently using 
> > Tomcat version 5.0.28.  Could somone please describe how 
> this could be done?  Thanks.
> >   
> The system property "java.version" will probably give you 
> what you want.
> 
> D
> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To 
> unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Programmatically Determine JVM Version used by Tomcat

Posted by David kerber <dc...@verizon.net>.
bachuba wrote:
> Hi,
> I'm fairly new to using Tomcat, but need to determine what JVM version (or
> at least the path to it) a running Tomcat service is currently using on a
> Windows system.  If I run tomcat5w.exe and click on the Java tab, I notice
> the informaiton is listed there, but I would like to be able to get at that
> programmatically.  We are currently using Tomcat version 5.0.28.  Could
> somone please describe how this could be done?  Thanks.
>   
The system property "java.version" will probably give you what you want.

D



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Programmatically Determine JVM Version used by Tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: bachuba [mailto:bachuba@yahoo.com] 
> Subject: Programmatically Determine JVM Version used by Tomcat
> 
> I'm fairly new to using Tomcat, but need to determine what 
> JVM version (or at least the path to it)

It's available in a system property:

    System.getProperty("java.runtime.version")

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Programmatically Determine JVM Version used by Tomcat

Posted by bachuba <ba...@yahoo.com>.
Thanks, this is just what I was looking for.



Mark H. Wood wrote:
> 
> Well, that was silly.  The Tomcat HTML Manager already provides the JRE
> version at the bottom of the page, if you wanted to manually check
> it.  To check by script, you could use the plain Manager:
> 
> mwood@mhw ~ $ wget --quiet -O - --user USER --password PASSWORD
> http://localhost:8080/manager/serverinfo
> OK - Server info
> Tomcat Version: Apache Tomcat/5.5
> OS Name: Linux
> OS Version: 2.6.18-gentoo-r6
> OS Architecture: i386
> JVM Version: 1.5.0_11-b03
> JVM Vendor: Sun Microsystems Inc.
> 
> -- 
> Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
> Typically when a software vendor says that a product is "intuitive" he
> means the exact opposite.
> 
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/Programmatically-Determine-JVM-Version-used-by-Tomcat-tf3884522.html#a11060919
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Programmatically Determine JVM Version used by Tomcat

Posted by "Mark H. Wood" <mw...@IUPUI.Edu>.
Well, that was silly.  The Tomcat HTML Manager already provides the JRE
version at the bottom of the page, if you wanted to manually check
it.  To check by script, you could use the plain Manager:

mwood@mhw ~ $ wget --quiet -O - --user USER --password PASSWORD http://localhost:8080/manager/serverinfo
OK - Server info
Tomcat Version: Apache Tomcat/5.5
OS Name: Linux
OS Version: 2.6.18-gentoo-r6
OS Architecture: i386
JVM Version: 1.5.0_11-b03
JVM Vendor: Sun Microsystems Inc.

-- 
Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
Typically when a software vendor says that a product is "intuitive" he
means the exact opposite.


Re: Programmatically Determine JVM Version used by Tomcat

Posted by "Mark H. Wood" <mw...@IUPUI.Edu>.
If you fetch 'java.runtime.version' in freestanding code then you'll
get the version of the current default JRE, which might not be what
Tomcat is using.  But if you fetch it in a servlet, then you should
get the version of the JRE that's running Tomcat, no?

<?xml version="1.0" encoding="US-ASCII" ?>
<%@ page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"
/>
<title>Dummy Web Application</title>
</head>
<body>
<p>This is a test.</p>
<table border='1px'>
<tr>
<td>Java Runtime Environment version</td>
<td><%=System.getProperty("java.runtime.version")%></td>
</tr>
</table>
</body>
</html>

-- 
Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
Typically when a software vendor says that a product is "intuitive" he
means the exact opposite.


RE: Programmatically Determine JVM Version used by Tomcat

Posted by Robert Harper <ro...@iat-cti.com>.
One problem with this is that you have to know where the JRE for 1.5 was
installed. There is nothing that guarantees that the install path is the
default. You might try to get the version information from the binary that
is running if the OS version supports it. It might be more appropriate to
try to load a required class and report the error when you encounter it.

Robert S. Harper
Senior Engineer
Information Access Technology, Inc.
1100 East 6600 South, Suite 300
Salt Lake City Utah USA 84121-7411
(801)265-8800 Ext. 255 
FAX (801)265-8880
 

This e-mail is intended only for the addressee and may contain confidential
and/or privileged information. Any review, retransmission, or action taken
upon this information by persons other than the intended recipient is
prohibited by law. If you received this communication in error, please
contact us immediately at 801-265-8800. Although this e-mail and any
attachments are believed to be free of any virus or other defect, it is the
responsibility of the recipient to ensure that anything received or opened
is virus free. No responsibility is accepted by IAT for any loss or damage
in the event that such a virus or defect exists.
-----Original Message-----
From: bachuba [mailto:bachuba@yahoo.com] 
Sent: Thursday, June 07, 2007 2:48 PM
To: users@tomcat.apache.org
Subject: Re: Programmatically Determine JVM Version used by Tomcat


I believe the suggested solutions will only poll the java version installed
on the computer, correct?  I probably should have provided a little more
detail on what is needed.

Tomcat is being installed with JAVA_HOME pointed toward a 1.4 version of
java.  Later, JAVA 1.5 is installed and JAVA_HOME updated, but the Tomcat
service is still using 1.4 (verified by running tomcat5w.exe and clicking on
the Java tab).  This value either needs to be updated or the Tomcat service
uninstalled and reinstalled with the new JAVA_HOME.  Sometimes this doesn't
happen causing issues with our application, so I'd like to write a program
that detects when this situation occurs (JAVA_HOME set to 1.5, Tomcat using
1.4).  Thanks.
-- 
View this message in context:
http://www.nabble.com/Programmatically-Determine-JVM-Version-used-by-Tomcat-
tf3884522.html#a11015926
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Programmatically Determine JVM Version used by Tomcat

Posted by bachuba <ba...@yahoo.com>.
I believe the suggested solutions will only poll the java version installed
on the computer, correct?  I probably should have provided a little more
detail on what is needed.

Tomcat is being installed with JAVA_HOME pointed toward a 1.4 version of
java.  Later, JAVA 1.5 is installed and JAVA_HOME updated, but the Tomcat
service is still using 1.4 (verified by running tomcat5w.exe and clicking on
the Java tab).  This value either needs to be updated or the Tomcat service
uninstalled and reinstalled with the new JAVA_HOME.  Sometimes this doesn't
happen causing issues with our application, so I'd like to write a program
that detects when this situation occurs (JAVA_HOME set to 1.5, Tomcat using
1.4).  Thanks.
-- 
View this message in context: http://www.nabble.com/Programmatically-Determine-JVM-Version-used-by-Tomcat-tf3884522.html#a11015926
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org