Atom Feed SITE FEED   ADD TO GOOGLE READER

Discovering the platform profile from Java

What's the simplest way to get CPU speed, amount of RAM, OS version, and other hardware details from the running JVM? I'm putting together a yet-to-be-announced tool that will include hardware specs in its reporting.

So far, I've been able to get the hardware profile on Mac OS X using sysctl and on Linux using /proc/cpuinfo and /proc/meminfo:
java.version: 1.5.0_13
java.vm.name: Java HotSpot(TM) Client VM
os.arch: i386
os.name: Mac OS X
os.version: 10.5.1
user.name: jessewilson
host.name: jessewilson-macbookpro-2.local
os.kernel.version: 9.1.0
host.model: MacBookPro1,1
host.cpus: 2
host.cpu.speeds: 2000000000
host.cpu.arch: i386
host.cpu.bits.physical: 32
host.cpu.names: Genuine Intel(R) CPU 1500 @ 2.00GHz
host.cpu.caches.l2: 2097152
host.memory.physical: 2147483648

This comes from a quick-n-dirty Java app, HostInfo.java. Curious - anyone know of a simpler approach? Or a more reliable API? I'm not interested in JNI or nontrivial applications, since they complicate deployment.

Still to do - figure out what's necessary to discover this information on the Windows platform...
What about the classes in java.lang.management, like OperatingSystemMXBean, MemoryMXBean,
or RuntimeMXBean?
Cool, I didn't know about those classes. I should read the

Without them, I think there's no platform-independent way you can rely on.
Sweet, I'd never heard of these classes either! And they're in Java SE! This is fantastic.

I'm still going to keep around my HostInfo class for CPU speed and physical memory, but these classes provide a better API and much more reliable access. Thanks!
This is quite useful. You can use systeminfo command in windows.
You can get stuff here too:

http://commons.apache.org/lang/api-release/org/apache/commons/lang/SystemUtils.html