I need to write a small client application which gives CPU information such as CPU_TYPE, Processor_Speed, Serial number, UUID, operating system, physical memory and etc...
Does any one knows very straight approach for getting these information.
Thanks in advance开发者_开发知识库 Viswanathan G
For CPU try org.hyperic.sigar.cmd.CpuInfo. For OS try System.getProperties().
On Windows you could use WMI to get the necessary information by simply executing a (or several) simple scripts.
On linux you can do something similar by parsing information out of proc/cpuinfo
and other stuff (not an expert there).
minimal example for win
I'm not aware of any framework that is crossplatform for this kind of information - mostly because there's just no way to get this information without delving deep into the platforms insides. Depending on how much data you need you may get by by parsing the data from some trivial scripts or you could use frameworks for all platforms you need.
I'm pretty certain there's no way to do this in pure Java. You'll need to use JNI or some other native-code interface to get information from the underlying OS. Unfortunately, this will also make your Java program not portable to other operating systems.
I'd just call some native command for that. On Linux it is cat /proc/cpuinfo
.
Java is not good tool for this purpose but still can easily collect information from such native tools/calls.
精彩评论