Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the processor name and registered to informations using java?

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.

enter image description here

like image 389
bharath Avatar asked Apr 04 '11 09:04

bharath


2 Answers

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.

like image 33
Heiko Rupp Avatar answered Nov 20 '22 07:11

Heiko Rupp


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
like image 83
aioobe Avatar answered Nov 20 '22 07:11

aioobe