Maven包
包使用较新的版本,旧版本在amd或者win11会有参数不齐的bug
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>5.8.1</version>
</dependency>
具体代码
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.HardwareAbstractionLayer;
public class HardWareInfo {
public static void main(String[] args) {
SystemInfo systemInfo = new SystemInfo();
HardwareAbstractionLayer hardware = systemInfo.getHardware();
CentralProcessor processor = hardware.getProcessor();
System.out.println(processor.toString());
}
}
效果
AMD Ryzen 7 4800H with Radeon Graphics 1 physical CPU package(s) 8 physical CPU core(s) 16 logical CPU(s) Identifier: AuthenticAMD Family 23 Model 96 Stepping 1 ProcessorID: **************************** Microarchitecture: unknown
|