jlibs.core.lang
Enum OS

java.lang.Object
  extended by java.lang.Enum<OS>
      extended by jlibs.core.lang.OS
All Implemented Interfaces:
Serializable, Comparable<OS>

public enum OS
extends Enum<OS>

This enum contains values for each type of OS.

To get the current OS:

 OS myos = OS.get();
 System.out.println(myos);
 
To check whether your OS is windows or unix;
 OS myos = OS.get();
 System.out.println("isWindows: "+myos.isWindows());
 System.out.println("isUnix: "+myos.isUnix());
 
When your OS is not recognized, OS.get() returns OS.OTHER

There is another usefult method which might be required rarely;

 String osName = System.getProperty("os.name");
 OS os = OS.get(osName);
 
This might be handy, if your app is distributed and and want to find out the os of remote JVM process

Author:
Santhosh Kumar T

Enum Constant Summary
COMPAQ_OPEN_VMS
           
COMPAQ_TRU64_UNIX
           
FREEBSD
           
HP_UX
           
IBM_AIX
           
LINUX
           
MAC
           
OS2
           
OTHER
          Unrecognized OS
SGI_IRIX
           
SOLARIS
           
SUN_OS
           
WINDOWS_2000
           
WINDOWS_7
           
WINDOWS_95
           
WINDOWS_98
           
WINDOWS_NT
           
WINDOWS_OTHER
           
WINDOWS_VISTA
           
 
Method Summary
static OS get()
           
static OS get(String osName)
           
 boolean isUnix()
           
 boolean isWindows()
           
static OS valueOf(String name)
          Returns the enum constant of this type with the specified name.
static OS[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

WINDOWS_NT

public static final OS WINDOWS_NT

WINDOWS_95

public static final OS WINDOWS_95

WINDOWS_98

public static final OS WINDOWS_98

WINDOWS_2000

public static final OS WINDOWS_2000

WINDOWS_VISTA

public static final OS WINDOWS_VISTA

WINDOWS_7

public static final OS WINDOWS_7

WINDOWS_OTHER

public static final OS WINDOWS_OTHER

SOLARIS

public static final OS SOLARIS

LINUX

public static final OS LINUX

HP_UX

public static final OS HP_UX

IBM_AIX

public static final OS IBM_AIX

SGI_IRIX

public static final OS SGI_IRIX

SUN_OS

public static final OS SUN_OS

COMPAQ_TRU64_UNIX

public static final OS COMPAQ_TRU64_UNIX

MAC

public static final OS MAC

FREEBSD

public static final OS FREEBSD

OS2

public static final OS OS2

COMPAQ_OPEN_VMS

public static final OS COMPAQ_OPEN_VMS

OTHER

public static final OS OTHER
Unrecognized OS

Method Detail

values

public static OS[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (OS c : OS.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static OS valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

isWindows

public boolean isWindows()
Returns:
true if this OS belongs to windows family

isUnix

public boolean isUnix()
Returns:
true if this OS belongs to *nix family

get

public static OS get(String osName)
Parameters:
osName - name of OS as returned by System.getProperty("os.name")
Returns:
OS for the specified osName

get

public static OS get()
Returns:
OS on which this JVM is running


Copyright © 2018. All rights reserved.