Interface OsService

All Superinterfaces:
Service
All Known Implementing Classes:
DefaultOsService

@Experimental public interface OsService extends Service
Service for detecting and providing information about the operating system (OS) on which the application is running.

This service provides a platform-independent way to:

  • Query basic OS information like name, architecture, and version
  • Determine the OS family (e.g., Windows, Unix, Mac)
  • Check if the current OS is Windows-based

The service implementation uses system properties to detect OS characteristics:

  • os.name: The operating system name
  • os.arch: The operating system architecture
  • os.version: The operating system version

Supported OS families include:

  • windows: All Windows variants
  • win9x: Windows 95, 98, ME, CE
  • winnt: Windows NT variants
  • unix: Unix-like systems (including Linux)
  • mac: macOS (including Darwin)
  • os/2: OS/2 variants
  • netware: Novell NetWare
  • dos: DOS variants
  • tandem: Tandem systems
  • openvms: OpenVMS
  • z/os: z/OS and OS/390
  • os/400: OS/400
Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the OS architecture as reported by the system property "os.arch".
    Returns the OS family name based on OS detection rules.
    boolean
    Checks if the current operating system belongs to the Windows family.
    Returns the OS full name as reported by the system property "os.name".
    Returns the OS version as reported by the system property "os.version".
  • Method Details

    • name

      Returns the OS full name as reported by the system property "os.name". The value is converted to lowercase for consistency.
      Returns:
      the operating system name (never null)
    • arch

      Returns the OS architecture as reported by the system property "os.arch". The value is converted to lowercase for consistency.
      Returns:
      the operating system architecture (never null)
    • version

      @Nonnull String version()
      Returns the OS version as reported by the system property "os.version". The value is converted to lowercase for consistency.
      Returns:
      the operating system version (never null)
    • family

      @Nonnull String family()
      Returns the OS family name based on OS detection rules. This categorizes the OS into one of the supported families (e.g., "windows", "unix", "mac").
      Returns:
      the operating system family name (never null)
    • isWindows

      boolean isWindows()
      Checks if the current operating system belongs to the Windows family. This includes all Windows variants (95, 98, ME, NT, 2000, XP, Vista, 7, 8, 10, 11).
      Returns:
      true if the current OS is any Windows variant, false otherwise