OSHI retrieves operating system and hardware information in Java without extra native installs, covering CPUs, memory, disks, processes, sensors, and more.
Overview
OSHI is a free Java library for native operating system and hardware information. It aims to work cross-platform without requiring installation of additional native libraries beyond what the library bundles.
You can query OS version, processes, memory and CPU usage, disks and partitions, devices, sensors, network interfaces, GPUs, containers, printers, and many other metrics. Supported platforms include Windows, macOS, Linux (including Android), and several UNIX variants.
The project offers JNA-based and FFM-based native access implementations plus a pure-Java path for Linux and NetBSD. Optional companion modules add demos, Micrometer metrics, and JMH benchmarks.
Teams add OSHI through Maven or Gradle, instantiate SystemInfo, and read structured data through documented APIs. Configuration can be tuned at startup via properties or GlobalConfig.
Key features
- Cross-platform system and hardware queries
- Process, CPU, and memory details
- Disk, filesystem, and network statistics
- JNA and FFM native backends
- Optional Micrometer metrics module
- Sensor and GPU readings on supported hardware
- Container cgroup usage on Linux
- Pure-Java nativefree mode for some platforms
Use cases
- Collecting host metrics inside Java applications
- Building monitoring or inventory dashboards
- Sampling process and resource usage
- Reading hardware sensors from Java services