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
Include OSHI and its dependencies on your classpath.
- We strongly recommend you add
oshi-core(and/oroshi-core-ffm) as a dependency to your project dependency manager such as Maven or Gradle. Transitive dependencies (includingoshi-commonand JNA) are resolved automatically. - If you manage JAR files manually, download all needed JARs from the
oshi-distzip file attached to each GitHub release. It containsoshi-common,oshi-core, andoshi-core-ffmplus their runtime dependencies; theoshi-demoexamples and their dependencies are not included. See UPGRADING.md for details. - For Windows, consider the optional
jLibreHardwareMonitordependency 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
NoClassDefFoundErrororNoSuchMethodErrorproblems.
- We strongly recommend you add
Create a new instance of
SystemInfo(implementingSystemInfoProvider):// Automatically selects the best available implementation based on your classpath and runtime. SystemInfoProvider si = SystemInfoFactory.create();Classpath JDK Selected implementation oshi-coreonly8+ JNA ( oshi.SystemInfo)oshi-core-ffmonly25+ FFM ( oshi.ffm.SystemInfo)Both oshi-coreandoshi-core-ffm8+ FFM (JDK 25+), otherwise JNA oshi-commononly8+ No --enable-native-accessrequired — Linux and NetBSD only (oshi.nativefree.SystemInfo)You can also instantiate directly:
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)Use the getters from
SystemInfoto access hardware or operating system components, such as: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:
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:
jbang json@oshi/oshi # JSON dump of system info
jbang gui@oshi/oshi # Swing GUI dashboard
See the oshi-demo README for all available dem