I'm writing an installer that will tune the configuration of the product for the particular hardware on which it will be run. In particular, I want to determine how much physical RAM is installed in the system so I can estimate how much memory to allocate to the product when it runs.
Ideally, I'd like to do this in a platform-independent, pure Java way, as the installer will need to run on several different platforms, but in case this isn't possible, solutions for Windows are preferred as that's the most common deployment platform.
In this case, it's safe to assume that the product will be the only/main application running on the box, so I don't have to worry about squeezing anyone else out. I don't want to over-allocate as this, in our experience, can hurt performance.
解决方案
For windows, you'll need to access WMI - this will get you going: Accessing Windows Management Instrumentation (WMI) from Java.
You'll want to use this section of WMI: Win32_LogicalMemoryConfiguration.
There may be a pure java way of doing this, but I am unaware of it.