For example,
if (OperatingSystem.isWindows()) { // Windows only code. } else if (OperatingSystem.isLinux()) { // Linux only code }
if (OperatingSystem.current() == OperatingSystem.WINDOWS) { // Windows only code. }
int port() { return switch(OperatingSystem.current()) { case LINUX->32768; case AIX->32768; case MACOS->49152; case WINDOWS->49152; }; }
| Modifier and Type | Field and Description |
|---|---|
| public static final OperatingSystem | AIX
The AIX Operating system. |
| private static final OperatingSystem | |
| public static final OperatingSystem | LINUX
Operating systems based on the Linux kernel. |
| public static final OperatingSystem | MACOS
The Mac OS X Operating system. |
| public static final OperatingSystem | WINDOWS
The Windows Operating system. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static OperatingSystem | |
| private static OperatingSystem | |
| public static boolean | Returns: true if built for the AIX operating systemReturns |
| public static boolean | Returns: true if built for the Linux operating systemReturns |
| public static boolean | Returns: true if built for the Mac OS X operating systemReturns |
| public static boolean | Returns: true if built for the Windows operating systemReturns |
| public static OperatingSystem | |
| public static OperatingSystem[] |
| AIX | back to summary |
|---|---|
| public static final OperatingSystem AIX The AIX Operating system. | |
| CURRENT_OS | back to summary |
|---|---|
| private static final OperatingSystem CURRENT_OS | |
| LINUX | back to summary |
|---|---|
| public static final OperatingSystem LINUX Operating systems based on the Linux kernel. | |
| MACOS | back to summary |
|---|---|
| public static final OperatingSystem MACOS The Mac OS X Operating system. | |
| WINDOWS | back to summary |
|---|---|
| public static final OperatingSystem WINDOWS The Windows Operating system. | |
| OperatingSystem | back to summary |
|---|---|
| private OperatingSystem() | |
| current | back to summary |
|---|---|
| public static OperatingSystem current() Returns the current operating system.
| |
| initOS | back to summary |
|---|---|
| private static OperatingSystem initOS() Returns the OperatingSystem of the build. Build time names are mapped to respective uppercase enum values. Names not recognized throw ExceptionInInitializerError with IllegalArgumentException. | |
| isAix | back to summary |
|---|---|
| public static boolean isAix() Returns
| |
| isLinux | back to summary |
|---|---|
| public static boolean isLinux() Returns
| |
| isMacOS | back to summary |
|---|---|
| public static boolean isMacOS() Returns
| |
| isWindows | back to summary |
|---|---|
| public static boolean isWindows() Returns
| |
| valueOf | back to summary |
|---|---|
| public static OperatingSystem valueOf(String name) | |
| values | back to summary |
|---|---|
| public static OperatingSystem[] values() | |