com.jgoodies.common.base

Class SystemUtils

public class SystemUtils extends Object

Provides convenience behavior to determine the operating system and Java version.

Version: $Revision: 1.6 $

Author: Karsten Lentzsch

Field Summary
static booleanIS_JAVA_1_4
True if this is Java 1.4.
static booleanIS_JAVA_5
True if this is Java 5.x.
static booleanIS_JAVA_5_OR_LATER
True if this is Java 5.x or later.
static booleanIS_JAVA_6
True if this is Java 6.
static booleanIS_JAVA_6_OR_LATER
True if this is Java 6.x or later.
static booleanIS_JAVA_7
True if this is Java 7.
static booleanIS_JAVA_7_OR_LATER
True if this is Java 6.x or later.
static booleanIS_OS_LINUX
Is true if this is Linux.
static booleanIS_OS_MAC
True if this is the Mac OS.
static booleanIS_OS_SOLARIS
True if this is Solaris.
static booleanIS_OS_WINDOWS
True if this is Windows.
static booleanIS_OS_WINDOWS_2000
True if this is Windows 2000.
static booleanIS_OS_WINDOWS_6_OR_LATER
True if this is Windows Vista/Server 2008/7/2008 R2.
static booleanIS_OS_WINDOWS_98
True if this is Windows 98.
static booleanIS_OS_WINDOWS_ME
True if this is Windows ME.
static booleanIS_OS_WINDOWS_VISTA
True if this is Windows Vista or Server 2008.
static booleanIS_OS_WINDOWS_XP
True if this is Windows XP.
protected static StringJAVA_VERSION
The {@code os.name} System Property.
protected static StringOS_NAME
The {@code os.name} System Property.
protected static StringOS_VERSION
The {@code os.version} System Property.
Constructor Summary
protected SystemUtils()
Method Summary
protected static StringgetSystemProperty(String key)
Tries to look up the System property for the given key.
protected static booleanstartsWith(String str, String prefix)

Field Detail

IS_JAVA_1_4

public static final boolean IS_JAVA_1_4
True if this is Java 1.4.

IS_JAVA_5

public static final boolean IS_JAVA_5
True if this is Java 5.x. We check for a prefix of 1.5.

IS_JAVA_5_OR_LATER

public static final boolean IS_JAVA_5_OR_LATER
True if this is Java 5.x or later. Since we support only Java 5 or later, this is always true.

IS_JAVA_6

public static final boolean IS_JAVA_6
True if this is Java 6. We check for a prefix of 1.6.

IS_JAVA_6_OR_LATER

public static final boolean IS_JAVA_6_OR_LATER
True if this is Java 6.x or later. We check that it's neither 1.4 nor 1.5.

IS_JAVA_7

public static final boolean IS_JAVA_7
True if this is Java 7. We check for a prefix of 1.7.

IS_JAVA_7_OR_LATER

public static final boolean IS_JAVA_7_OR_LATER
True if this is Java 6.x or later. We check that it's neither 1.4 nor 1.5 nor 1.6.

IS_OS_LINUX

public static final boolean IS_OS_LINUX
Is true if this is Linux.

IS_OS_MAC

public static final boolean IS_OS_MAC
True if this is the Mac OS.

IS_OS_SOLARIS

public static final boolean IS_OS_SOLARIS
True if this is Solaris.

IS_OS_WINDOWS

public static final boolean IS_OS_WINDOWS
True if this is Windows.

IS_OS_WINDOWS_2000

public static final boolean IS_OS_WINDOWS_2000
True if this is Windows 2000.

IS_OS_WINDOWS_6_OR_LATER

public static final boolean IS_OS_WINDOWS_6_OR_LATER
True if this is Windows Vista/Server 2008/7/2008 R2.

IS_OS_WINDOWS_98

public static final boolean IS_OS_WINDOWS_98
True if this is Windows 98.

IS_OS_WINDOWS_ME

public static final boolean IS_OS_WINDOWS_ME
True if this is Windows ME.

IS_OS_WINDOWS_VISTA

public static final boolean IS_OS_WINDOWS_VISTA
True if this is Windows Vista or Server 2008.

IS_OS_WINDOWS_XP

public static final boolean IS_OS_WINDOWS_XP
True if this is Windows XP.

JAVA_VERSION

protected static final String JAVA_VERSION
The {@code os.name} System Property. Operating system name.

Defaults to {@code null}, if the runtime does not have security access to read this property or the property does not exist.

OS_NAME

protected static final String OS_NAME
The {@code os.name} System Property. Operating system name.

Defaults to {@code null}, if the runtime does not have security access to read this property or the property does not exist.

OS_VERSION

protected static final String OS_VERSION
The {@code os.version} System Property. Operating system version.

Defaults to {@code null}, if the runtime does not have security access to read this property or the property does not exist.

Constructor Detail

SystemUtils

protected SystemUtils()

Method Detail

getSystemProperty

protected static String getSystemProperty(String key)
Tries to look up the System property for the given key. In untrusted environments this may throw a SecurityException. In this case we catch the exception and answer an empty string.

Parameters: key the name of the system property

Returns: the system property's String value, or {@code null} if there's no such value, or an empty String when a SecurityException has been caught

startsWith

protected static boolean startsWith(String str, String prefix)
Copyright © 2009-2010 JGoodies Karsten Lentzsch. All Rights Reserved.