Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

oshi

> 数据库
Open source

Native Operating System and Hardware Information

5.3K stars0 likes1 views
WebsiteGitHub

About

Native Operating System and Hardware Information

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

  • Windows
  • macOS
  • Linux (Android)
  • UNIX (AIX, DragonFly BSD, FreeBSD, NetBSD, OpenBSD, Solaris (illumos))

Supported Features

  • Computer System and firmware, baseboard
  • Operating System and Version/Build, virtualization (hypervisor) detection
  • Physical (core) and Logical (hyperthreaded) CPUs, processor groups, NUMA nodes, caches, feature flags
  • System and per-processor load, usage tick counters, interrupts, uptime
  • Process uptime, CPU, memory usage, user/group, command line args, thread details
  • Services and daemons, login sessions, desktop windows, installed applications
  • Physical and virtual memory used/available
  • Mounted filesystems (type, usable and total space, options, reads and writes)
  • Disk drives (model, serial, size, reads and writes), partitions, and logical volume groups
  • Network interfaces (IPs, bandwidth in/out), network parameters, routing table, TCP/UDP statistics
  • Battery state (% capacity, time remaining, power usage stats)
  • Peripheral devices (USB, Bluetooth)
  • Connected displays (with EDID info), graphics and audio cards
  • GPU utilization, VRAM and shared memory used, temperature, power draw, clock speeds
  • Sensors (temperature, fan speeds, voltage) on some hardware
  • Container resource limits and usage (cgroup v1/v2)
  • Printers (name, status, driver)

Native Access Implementations

OSHI provides two native access implementations:

  • JNA (oshi-core): Uses Java Native Access. Supports JDK 8+. JPMS module: com.github.oshi.
  • FFM (oshi-core-ffm): Uses the JDK Foreign Function & Memory API. Requires JDK 25+. JPMS module: com.github.oshi.ffm.

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).

oshi-common also carries a third, pure-Java implementation (oshi.nativefree) that reads only procfs, sysfs, sysctl and other command-line tools. It needs no native access at all, so it runs without an --enable-native-access flag and without the warning the JDK prints when one is missing. It covers Linux and NetBSD only, and is selected when neither oshi-core nor oshi-core-ffm is on the classpath.

Downloads and Dependency Management

Stable Release Versions

  • JNA: oshi-core-7.6.1
  • FFM: oshi-core-ffm-7.6.1
  • Common: oshi-common-7.6.1

Snapshot builds of the next version are published to https://central.sonatype.com/repository/maven-snapshots/, which your build must be configured to use.

Legacy Versions

  • JDK7: oshi-core-3.13.6
  • JDK6: oshi-core-3.14.0

Usage

  1. Include OSHI and its dependencies on your classpath.

    • We strongly recommend you add oshi-core (and/or oshi-core-ffm) as a dependency to your project dependency manager such as Maven or Gradle. Transitive dependencies (including oshi-common and JNA) are resolved automatically.
    • If you manage JAR files manually, download all needed JARs from the oshi-dist zip file attached to each GitHub release. It contains oshi-common, oshi-core, and oshi-core-ffm plus their runtime dependencies; the oshi-demo examples and their dependencies are not included. See UPGRADING.md for details.
    • 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 (implementing SystemInfoProvider):

    java
    // Automatically selects the best available implementation based on your classpath and runtime.
    SystemInfoProvider si = SystemInfoFactory.create();
    Classpath JDK Selected implementation
    oshi-core only 8+ JNA (oshi.SystemInfo)
    oshi-core-ffm only 25+ FFM (oshi.ffm.SystemInfo)
    Both oshi-core and oshi-core-ffm 8+ FFM (JDK 25+), otherwise JNA
    oshi-common only 8+ No --enable-native-access required — Linux and NetBSD only (oshi.nativefree.SystemInfo)

    You can also instantiate directly:

    java
    SystemInfoProvider si = new oshi.SystemInfo();            // JNA (oshi-core)
    SystemInfoProvider si = new oshi.ffm.SystemInfo();        // FFM (oshi-core-ffm, JDK 25+)
    SystemInfoProvider si = new oshi.nativefree.SystemInfo(); // no native access (oshi-common)
  3. Use the getters from SystemInfo to access hardware or operating system components, such as:

    java
    HardwareAbstractionLayer hal = si.getHardware();
    CentralProcessor cpu = hal.getProcessor();
    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.

Sample Output for Your System

To print a full report of your own system, clone the repository and run the SystemInfoTest main method. Both native implementations provide one:

bash
git clone https://github.com/oshi/oshi.git && cd oshi

# Build and install the modules first, so the shared oshi-common classes resolve
./mvnw install -DskipTests

# JNA (oshi-core), JDK 8+
./mvnw exec:java -pl oshi-core \
  -Dexec.mainClass="oshi.SystemInfoTest" \
  -Dexec.classpathScope="test"

# FFM (oshi-core-ffm), JDK 25+
./mvnw exec:java -pl oshi-core-ffm \
  -Dexec.mainClass="oshi.ffm.SystemInfoTest" \
  -Dexec.classpathScope="test"

See SystemInfoTest.java for the source, or the pre-generated Sample Output for an example report.

Documentation

  • Javadocs — JNA | FFM
  • FAQ
  • Change Log
  • Performance Considerations
  • Major Version Breaking Changes
  • Sample Output
  • Applications and Projects using OSHI

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:

bash
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.

java
OshiMetrics.bindTo(registry, SystemInfoFactory.create());

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+.

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

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

Support

Please see SUPPORT.md.

OSHI for Enterprise

Available as part of the Tidelift Subscription

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

Please see SECURITY.md.

Continuous Integration Test 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:

  • Testing! Our CI testing is limited to a few platforms. Download and test the program on various operating systems/versions and hardware and help identify gaps that our limited development and testing may have missed. Specific high priority testing needs include:
    • Windows systems with over 64 logical processors
    • Raspberry Pi
    • Less common Linux distributions
  • Contributing code. See something that's not working right or could work better? Help us fix it! New contributors are welcome.
  • Documenting implementation. Our Wiki is sparse and the oshi-demo artifact is a place to host proof-of-concept ideas. Want to help new users follow in your footsteps?
  • Suggesting new features. Do you need OSHI to do something it doesn't currently do? Let us know.

Contributing to OSHI

  • How to Contribute
  • How to Release

Acknowledgments

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

  • SonarCloud for a range of code quality tools
  • GitHub Actions, AppVeyor, and CircleCI for continuous integration testing
  • CodeRabbit for automated AI code review
  • The Claude for Open Source program for AI assistance used to broaden operating system coverage, accelerate the Foreign Function

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javacpu-usagedisk-utilizationforeign-function-and-memory-apihardware-information

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库