/*
* Enhydra Java Application Server Project
*
* The contents of this file are subject to the Enhydra Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License on
* the Enhydra web site ( http://www.enhydra.org/ ).
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific terms governing rights and limitations
* under the License.
*
* The Initial Developer of the Enhydra Application Server is Lutris
* Technologies, Inc. The Enhydra Application Server and portions created
* by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
* All Rights Reserved.
*
* Contributor(s):
*
* $Id: JavaVersion.java,v 1.15 2005/06/13 09:26:06 draganr Exp $
*/
package com.lutris.util;
/*
* JavaVersion can be used as a standalone main class
* to print the major version number of the executing JVM
* or it can return the version using the getVersion() method.
*
* @version $Revision: 1.15 $
* @author Shawn McMurdo
* @author Jason Hunter (jhunter@hyperreal.org)
*/
public class JavaVersion {
static {
setVersion();
}
public static String javaVersion;
public static void main(String argv[]) {
System.out.println(javaVersion);
}
public static String getVersion() {
return javaVersion;
}
private static void setVersion() {
// From Jason Hunter via Jakarta Tomcat
// This method includes software developed by the
// Apache Software Foundation <http://www.apache.org/>.
// Determine the Java version by looking at available classes
// java.lang.StrictMath was introduced in JDK 1.3
// java.lang.ThreadLocal was introduced in JDK 1.2
// java.lang.Void was introduced in JDK 1.1
// Count up version until a NoClassDefFoundError ends the try
try {
javaVersion = "1.0";
Class.forName("java.lang.Void");
javaVersion = "1.1";
Class.forName("java.lang.ThreadLocal");
javaVersion = "1.2";
Class.forName("java.lang.StrictMath");
javaVersion = "1.3";
}
catch (Throwable t) {
}
}
}