Java Clean Architecture Masterclass

Java Clean Architecture Masterclass28-29 May

Join

OSHI

MIT License Maven Central javadoc first-timers-only GitHub contributors

OSHI is a free native (JNA or FFM) Operating System and Hardware Information library for Java. It does not require the installation of any additional native libraries and aims to provide a cross-platform implementation to retrieve system information, such as OS version, processes, memory and CPU usage, disks and partitions, devices, sensors, etc.

Supported Platforms

Supported Features

Native Access Implementations

OSHI provides two native access implementations:

Both implementations share the same API interfaces from oshi-common. Choose one at compile time, or include both and select at runtime (see Usage below).

Downloads and Dependency Management

Stable Release Versions

Current Development (SNAPSHOT) Versions

Legacy Versions

Usage

  1. Include OSHI and its dependencies on your classpath.
    • We strongly recommend you add oshi-core as a dependency to your project dependency manager such as Maven or Gradle.
    • For Windows, consider the optional jLibreHardwareMonitor dependency if you need sensor information. Note the binary DLLs in this dependency are licensed under MPL 2.0.
    • For Android, you'll need to add the AAR artifact for JNA and exclude OSHI's transitive (JAR) dependency.
    • See the FAQ if you encounter NoClassDefFoundError or NoSuchMethodError problems.
  2. Create a new instance of SystemInfo
  3. Use the getters from SystemInfo to access hardware or operating system components, such as:
SystemInfo si = new SystemInfo(); // oshi.SystemInfo or oshi.ffm.SystemInfo
HardwareAbstractionLayer hal = si.getHardware();
CentralProcessor cpu = hal.getProcessor();

To include both implementations and select at runtime:

// Automatic selection — picks FFM on JDK 25+ (Windows/macOS/Linux), falls back to JNA
SystemInfoProvider si = SystemInfoFactory.create();
HardwareAbstractionLayer hal = si.getHardware();
OperatingSystem os = si.getOperatingSystem();

Some settings are configurable in the oshi.properties file, which may also be manipulated using the GlobalConfig class or using Java System Properties. This should be done at startup, as configuration is not thread-safe and OSHI does not guarantee re-reading the configuration during operation.

Documentation

Additional Modules

oshi-demo — Examples and Demos

Proof-of-concept examples including a Swing GUI, JSON output, JMX integration, and more. Try instantly with jbang:

jbang json@oshi/oshi    # JSON dump of system info
jbang gui@oshi/oshi     # Swing GUI dashboard

See the oshi-demo README for all available demos and usage instructions.

oshi-metrics — Micrometer Metrics

First-party Micrometer integration providing system, process, and container metrics following OpenTelemetry semantic conventions. Works with Prometheus, Grafana, Datadog, and any Micrometer-compatible backend.

OshiMetrics.bindTo(registry, si.getHardware(), si.getOperatingSystem());

See the oshi-metrics README for full setup, selective registration, and the complete list of metrics.

oshi-benchmark — JMH Benchmarks

JMH benchmarks comparing JNA and FFM implementations side by side. Requires JDK 25+.

./oshi-benchmark/scripts/run-benchmarks.sh

See the oshi-benchmark README for running specific benchmarks and custom JMH options.

Support

OSHI for Enterprise

Available as part of the Tidelift Subscription Tidelift

The maintainers of OSHI and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Security Contact Information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Continuous Integration Test Status

AppVeyor Build Status Cirrus CI Build Status Windows CI macOS CI Linux CI Unix CI SonarQube Bugs SonarQube Vulnerabilities SonarQube Maintainability SonarQube Reliability SonarQube Security Coverity Scan Build Status Codacy Badge CodeQL Coverage Status

How Can I Help?

OSHI originated as a platform-independent library that did not require additional software and had a license compatible with both open source and commercial products. We have developed a strong core of features on major Operating Systems, but we would love for you to help by:

Contributing to OSHI

Acknowledgments

Many thanks to the following companies for providing free support of Open Source projects including OSHI:

License

This project is licensed under the MIT License.

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.