问题
How we can get the processor name and registered to informations from PC? How is it possible through Java? I'm using windows OS.
Refer this image.
回答1:
There is a library called Sigar out there that can do all those fancy things.
The sigar jar can be called 'standalone' to explore the system:
$ java -jar sigar.jar
sigar> free
total used free
Mem: 8388608 7940428 448180
-/+ buffers/cache: 5872060 2516548
Swap: 262144 95296 166848
RAM: 8192MB
For this to work, you also need the respective .dll or .so in the classpath
In RHQ-project we use Sigar for many of those statistics - you can browse the code here.
回答2:
How its possible through java?
Generally, this is not possible to do in Java. You would have to go through an external program (see ProcessBuilder
) or through a native library (written in for instance C++).
You could do
System.getProperty("os.arch");
to get the OS architecture though. This gives "amd64"
on my machine.
The page here lists a few other system properties too, but these seem to be VM specific though:
sun.cpu.endian=little
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
来源:https://stackoverflow.com/questions/5536826/how-to-get-the-processor-name-and-registered-to-informations-using-java