Class SystemTools
Provides normalized OS-name checks for common platforms (AIX, FreeBSD, Linux, macOS, OpenVMS, Solaris, Windows) along with heuristics for identifying Cygwin, MinGW/MSYS2, and WSL environments. Also provides architecture detection for x86 and ARM families.
Designed for null-safety, testability, and minimal overhead. All system properties are cached at class load time.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringarch()Returns the normalized system architecture string.static booleanisAix()Determines if the current operating system is AIX.static booleanisArm()Determines if the current system architecture is any ARM variant.static booleanisArm32()Determines if the current system architecture is ARM 32-bit.static booleanisArm64()Determines if the current system architecture is ARM 64-bit.static booleanisCygwin()Determines if the current environment is running in a Cygwin environment.static booleanDetermines if the current operating system is FreeBSD.static booleanisLinux()Determines if the current operating system is Linux.static booleanisMacOS()Determines if the current operating system is macOS.static booleanisMinGw()Determines if the current environment is running in a MinGW/MSYS2 environment.static booleanDetermines if the current operating system is OpenVMS.static booleanDetermines if the current operating system is other than AIX, FreeBSD, Linux, macOS, OpenVMS, Solaris, or Windows.static booleanDetermines if the current operating system is Solaris.static booleanDetermines if the current operating system is Windows.static booleanisWsl()Determines if the current environment is Windows Subsystem for Linux.static booleanisX64()Determines if the current system architecture is x86 64-bit.static booleanisX86()Determines if the current system architecture is x86 32-bit.static booleanDetermines if the current system architecture is any x86 variant.
-
Method Details
-
arch
Returns the normalized system architecture string.Equivalent to
System.getProperty("os.arch").toLowerCase(Locale.ROOT). Use theis*methods for reliable checks instead of comparing this value directly, asos.archvalues vary across JVM implementations.- Returns:
- the architecture string in lowercase, or empty string if unavailable
- Since:
- 1.3
-
isAix
public static boolean isAix()Determines if the current operating system is AIX.- Returns:
trueif the operating system is AIX,falseotherwise- Since:
- 1.0
-
isArm
public static boolean isArm()Determines if the current system architecture is any ARM variant.Equivalent to
isArm32() || isArm64().- Returns:
trueif the architecture is ARM 32-bit or 64-bit,falseotherwise- Since:
- 1.3
-
isArm32
public static boolean isArm32()Determines if the current system architecture is ARM 32-bit.Checks
os.archfor"arm","arm32", or"armv*"without"64". Covers older Raspberry Pi, Android devices, etc.- Returns:
trueif the architecture is ARM 32-bit,falseotherwise- Since:
- 1.3
-
isArm64
public static boolean isArm64()Determines if the current system architecture is ARM 64-bit.Checks
os.archfor"aarch64"or"arm64". Covers Apple Silicon, AWS Graviton, Raspberry Pi 64-bit, etc.- Returns:
trueif the architecture is ARM64,falseotherwise- Since:
- 1.3
-
isCygwin
public static boolean isCygwin()Determines if the current environment is running in a Cygwin environment.This method delegates to
isCygwin(String, Function)using the current OS name andSystem.getenv(java.lang.String)as the environment provider. For testing, useisCygwin(String, Function)directly with a custom environment provider.Heuristic-based detection; may have false positives on Windows with Unix-like tools.
- Returns:
trueif the environment is detected as Cygwin,falseotherwise- Since:
- 1.0
-
isFreeBsd
public static boolean isFreeBsd()Determines if the current operating system is FreeBSD.- Returns:
trueif the operating system is FreeBSD,falseotherwise- Since:
- 1.0
-
isLinux
public static boolean isLinux()Determines if the current operating system is Linux.- Returns:
trueif the operating system is Linux,falseotherwise- Since:
- 1.0
-
isMacOS
public static boolean isMacOS()Determines if the current operating system is macOS.- Returns:
trueif the OS is macOS,falseotherwise- Since:
- 1.0
-
isMinGw
public static boolean isMinGw()Determines if the current environment is running in a MinGW/MSYS2 environment.This method delegates to
isMinGw(String, Function)using the current OS name andSystem.getenv(java.lang.String)as the environment provider. For testing, useisMinGw(String, Function)directly with a custom environment provider.Heuristic-based detection; may have false positives on Windows with Unix-like tools.
- Returns:
trueif the environment is detected as MinGW/MSYS2,falseotherwise- Since:
- 1.0
-
isOpenVms
public static boolean isOpenVms()Determines if the current operating system is OpenVMS.- Returns:
trueif the operating system is OpenVMS,falseotherwise- Since:
- 1.0
-
isOtherOs
public static boolean isOtherOs()Determines if the current operating system is other than AIX, FreeBSD, Linux, macOS, OpenVMS, Solaris, or Windows.- Returns:
trueif the operating system is none of the above,falseotherwise- Since:
- 1.0
-
isSolaris
public static boolean isSolaris()Determines if the current operating system is Solaris.- Returns:
trueif the operating system is Solaris,falseotherwise- Since:
- 1.0
-
isWindows
public static boolean isWindows()Determines if the current operating system is Windows.- Returns:
trueif the operating system is Windows,falseotherwise- Since:
- 1.0
-
isWsl
public static boolean isWsl()Determines if the current environment is Windows Subsystem for Linux.Checks
/proc/versionfor"Microsoft"or"WSL"signatures. Result is cached at class load time.- Returns:
trueif running under WSL,falseotherwise- Since:
- 1.3
-
isX64
public static boolean isX64()Determines if the current system architecture is x86 64-bit.Checks
os.archfor"amd64"or"x86_64". Covers Intel/AMD 64-bit, including Apple Intel Macs.- Returns:
trueif the architecture is x86 64-bit,falseotherwise- Since:
- 1.3
-
isX86
public static boolean isX86()Determines if the current system architecture is x86 32-bit.Checks
os.archfor"x86","i386","i486","i586", or"i686".- Returns:
trueif the architecture is x86 32-bit,falseotherwise- Since:
- 1.3
-
isX86Family
public static boolean isX86Family()Determines if the current system architecture is any x86 variant.Equivalent to
isX86() || isX64().- Returns:
trueif the architecture is x86 32-bit or 64-bit,falseotherwise- Since:
- 1.3
-