CLI tool
oshi/oshi avatar
oshi/oshi

OSHI 7.6: Java System Information with Two Native Backends and a Pure-Java Fallback

Project brief: Native Operating System and Hardware Information. OSHI is a free native (JNA or FFM) Operating System and Hardware Information library for Java.

5,265 stars916 forksJavaMIT

At a glance

What is it?
OSHI is a Java library for operating system and hardware details, offering JNA and FFM implementations plus a native-free option. This review covers its architecture, setup, and practical limits for engineers evaluating it.
Who is it for?
Adopt OSHI if you need cross-platform OS and hardware data in Java without writing native code, and you can pick a backend that fits your JDK. The JNA version supports JDK 8+, while FFM requires JDK 25+.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 10 days ago.
What is it written in?
Mainly Java, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What OSHI Solves and Who Needs It

OSHI fills a gap for Java developers who need operating system and hardware information without writing platform-specific native code. The README lists a wide range of data: OS version, processes, memory and CPU usage, disks, network interfaces, battery state, sensors, and even GPU utilization. It targets applications like monitoring tools, system dashboards, and configuration utilities that must run on multiple operating systems. The library abstracts platform differences behind a common API, so you write one set of calls and get results on Windows, macOS, Linux, Android, and several UNIX variants. This is a practical fit for Java projects that previously had to use JNI or shell out to system commands. The main audience is Java engineers who need reliable system data but do not want to maintain native bindings themselves.

Two Native Backends and a Pure-Java Fallback

OSHI's key architectural decision is offering two native access implementations plus a third that avoids native access entirely. The JNA backend, in oshi-core, uses Java Native Access and supports JDK 8+. The FFM backend, in oshi-core-ffm, uses the JDK Foreign Function and Memory API and requires JDK 25+. Both share the same API interfaces from oshi-common. The README explains that you can include one or both, and the SystemInfoFactory.create() method selects the best available implementation based on classpath and runtime. If both are present, FFM wins on JDK 25+, otherwise JNA. There is also a pure-Java implementation in oshi-common called oshi.nativefree, which reads procfs, sysfs, sysctl, and command-line tools. It requires no native access and no --enable-native-access flag, but it only supports Linux and NetBSD. This three-tier design is a genuine strength: it gives you a migration path from JNA to FFM without changing your code, and a fallback for restricted environments.

Getting OSHI Running: Dependencies and First Calls

Setup follows standard Maven or Gradle dependency management. You add oshi-core and/or oshi-core-ffm to your project, and transitive dependencies like oshi-common and JNA resolve automatically. For manual JAR management, the README points to the oshi-dist zip attached to each GitHub release, which contains oshi-common, oshi-core, and oshi-core-ffm plus runtime dependencies. After adding the dependency, you create a SystemInfoProvider instance. The recommended way is SystemInfoProvider si = SystemInfoFactory.create(); which auto-selects the backend. You can also instantiate directly: new oshi.SystemInfo() for JNA, new oshi.ffm.SystemInfo() for FFM, or new oshi.nativefree.SystemInfo() for the pure-Java path. Then you access components like HardwareAbstractionLayer hal = si.getHardware(); CentralProcessor cpu = hal.getProcessor(); OperatingSystem os = si.getOperatingSystem();. The README also mentions an oshi.properties file for configuration, which you can manipulate via the GlobalConfig class or Java System Properties, but it warns that configuration is not thread-safe and should be set at startup.

The Native-Free Path: A Useful But Narrow Option

The nativefree implementation is an interesting compromise. It reads procfs, sysfs, sysctl, and other command-line tools, so it needs no native access at all. That means no --enable-native-access flag and no JDK warning. But it only covers Linux and NetBSD. This is a real limitation. If your application targets Windows or macOS, you cannot use this backend. Even on Linux, the data available through procfs and sysfs may be less complete than what the JNA or FFM backends can retrieve, especially for hardware details like sensors or GPU utilization. The README does not specify exact coverage differences, so you should test what data you actually get. The nativefree path is best for simple Linux containers or embedded environments where native access is blocked, but it is not a general replacement for the native backends.

Licensing and Optional Dependencies

OSHI itself is MIT licensed, which is permissive and generally easy to adopt. However, the README notes that for Windows sensor information, you may consider the optional jLibreHardwareMonitor dependency, and its binary DLLs are licensed under MPL 2.0. MPL 2.0 is a file-level copyleft license, which has implications for how you distribute those DLLs. This is a concrete licensing consideration that engineers must evaluate before enabling sensor support on Windows. The README does not provide legal advice, but it flags the dependency clearly. For Android, you need to add the JNA AAR artifact and exclude OSHI's transitive JAR dependency, which is a specific setup step that affects your build configuration.

Maintenance and Upgrade Considerations

The repository is actively maintained, with recent releases including 7.6.0 in August 2026, following 7.5.0 and 7.4.4 in the same month. The README references an UPGRADING.md file that contains dependency details, which suggests the project takes migration seriously. However, the README does not provide details on breaking changes between versions. The main upgrade cost comes from the JDK requirement for the FFM backend. If you are on JDK 8 to 24, you must use the JNA backend. If you move to JDK 25+, you can switch to FFM, but you need to ensure your code does not rely on JNA-specific behavior. The API is shared, so most code should work unchanged, but the nativefree implementation has a different class (oshi.nativefree.SystemInfo) and limited platform support, so that path is not a drop-in for all platforms.

Limitations and Wrong-Tool Scenarios

OSHI is not the right tool if you need real-time, low-level hardware control or if you need sensor data on platforms where the README does not guarantee support. The feature list includes sensors, but the README says 'on some hardware'. That vagueness means you cannot assume temperature or fan readings exist on every machine. Similarly, GPU utilization, VRAM, and power draw are listed, but the README does not specify which operating systems or GPU vendors are covered. The configuration mechanism via oshi.properties is not thread-safe, so you must set it at startup, which is a constraint for applications that dynamically change settings. Also, the nativefree backend only covers Linux and NetBSD, so if you try to use it on Windows or macOS, it will not work. These are genuine limitations that could make OSHI the wrong choice for cross-platform applications that require consistent sensor or GPU data across all target systems.

Alternative Approaches: JNA vs. FFM vs. System Commands

The most direct alternative to OSHI is writing your own JNA or FFM bindings to platform APIs. That gives you full control over what you call and when, but it means maintaining platform-specific code for each OS. OSHI abstracts that away, which is its main value. Another alternative is to use system commands like 'top', 'df', or 'sysctl' and parse their output. This is what the nativefree backend does, and it works on Linux and NetBSD, but it is fragile across OS versions and locales. OSHI's JNA and FFM backends call native APIs directly, which is more reliable than parsing command output. The FFM backend is particularly notable because it uses the JDK's Foreign Function and Memory API, which is a modern replacement for JNI and JNA. The README shows that FFM requires JDK 25+, so if you are on an older JDK, JNA is the only native option. Choosing between JNA and FFM is a matter of JDK version and future migration strategy.

Editorial conclusion

Adopt OSHI if you need cross-platform OS and hardware data in Java without writing native code, and you can pick a backend that fits your JDK. The JNA version supports JDK 8+, while FFM requires JDK 25+. Avoid it if you need deep sensor coverage on Windows without adding the optional MPL-2.0 jLibreHardwareMonitor dependency, or if you rely on the native-free path outside Linux and NetBSD. Before committing, verify that the specific data you need, such as GPU details or sensor readings, works on your target OS and hardware, because the README lists these features but does not guarantee availability on every platform. Also confirm your JDK version and module path, since the FFM backend demands JDK 25+ and both implementations use JPMS modules.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
  4. Release notes
Community notes

Community notes