Skip to content

Instantly share code, notes, and snippets.

@krishnact
Last active January 8, 2019 19:12
Show Gist options
  • Save krishnact/315614e2dc402c31893733423fe7747e to your computer and use it in GitHub Desktop.
Save krishnact/315614e2dc402c31893733423fe7747e to your computer and use it in GitHub Desktop.
How to get CPU ID in Java?
use following dependency:
<dependency>
<artifactId>oshi-core</artifactId>
<groupId>com.github.oshi</groupId>
<version>3.11.0</version>
</dependency>
and use this code:
public static String getCPUId() {
oshi.SystemInfo si = new oshi.SystemInfo();
String procId = si.getHardware().getProcessor().getProcessorID() ;
return procId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment