I am creating an application similar to CPU-Z to obtain the full specifications of the device, such as details of the cache, graphics card, temperature, number of cores and threads, and frequency.
The problem is that I searched for a long time and found only a little thing until I felt frustrated. Are there any offices in Java that support this? I want a code to help.
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.lang.management.ManagementFactory;
import com.sun.management.OperatingSystemMXBean;
public class Cpu {
public static void main(String[] args) {
OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
long cacheSize = osBean.getFreePhysicalMemorySize();
System.out.println( + osBean.getVendor());
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for (GraphicsDevice gd : gs) {
System.out.println(gd.getIDstring());
System.out.println(gd.getDisplayMode().getWidth()
+ "x" + gd.getDisplayMode().getHeight());
}
System.out.println(gs[0].getConfigurations()[0].getDevice());
System.out.println(gs[0].getDefaultConfiguration().getDevice());
System.out.println("CACHE " + cacheSize / (1024 * 1024 * 1024) + " bytes");
System.out.println(osBean.getAvailableProcessors());
System.out.println((osBean.getTotalPhysicalMemorySize()) / (1024 * 1024 * 1024) + " bytes");
System.out.println(osBean.getProcessCpuLoad());
System.out.println(osBean.getProcessCpuTime());
System.out.println(osBean.getVersion());
System.out.println(osBean.getArch());
System.out.println(osBean.getName());
System.out.println(osBean.getSystemCpuLoad());
}
}
مهندس برمجي is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.