Package oshi


package oshi
[oshi-core API] Provides a cross-platform implementation to retrieve Operating System and Hardware Information, such as OS version, memory, CPU, disk, devices, sensors, etc.

Module Architecture

OSHI is organized into three modules:
  • oshi-common (com.github.oshi.common) - Interfaces, abstract base classes, POJOs, and utilities. This module contains no native code and requires no native access permissions.
  • oshi-core (this module) - Full OSHI implementation using JNA for native access. Supports all platforms (Windows, macOS, Linux, FreeBSD, OpenBSD, Solaris, AIX). Entry point: SystemInfo.
  • oshi-core-java25 - Alternative implementation using the Foreign Function and Memory (FFM) API (JDK 25+). Currently supports Windows, macOS, and Linux. Entry point: oshi.ffm.SystemInfo.

Native Access and JEP 472

Both oshi-core and oshi-core-java25 use native access to retrieve most system information. JEP 472 (JDK 24) causes the JVM to issue warnings when native code is loaded, and a future JDK release will require the --enable-native-access flag to permit it.

Applications that cannot or prefer not to enable native access can depend on oshi-common alone. This module provides the full OSHI API surface (interfaces and abstract base classes) along with utilities for parsing /proc and other OS-provided text files, executing system commands, and formatting output. To use it:

  1. Depend on the oshi-common artifact only (Maven: com.github.oshi:oshi-common).
  2. Extend the abstract base classes in oshi.hardware.common and oshi.software.common. For hardware, subclass AbstractHardwareAbstractionLayer and override its protected abstract create*() factory methods to return your platform-specific implementations. For software and individual components (e.g., AbstractOperatingSystem, AbstractCentralProcessor), override the protected abstract query*() methods with platform-specific logic using command-line tools, /proc parsing, or other non-native techniques.
This approach trades some coverage (not all information is available without native access) for compatibility with restricted JVM environments.
  • Class
    Description
    Deprecated.
    Use PlatformEnum instead.
    System information.