Take Hyperic SIGAR, a very popular Java API that lets you collect system information. It has two major drawbacks.
- It uses a native library (eg. hyperic-sigar-x86.dll), which you have to install separately from your application’s jar/war.
- It’s GPL v2. My legal department immediate flagged that as a no-go since we’re a commercial product.
Sounds like we could live with the first problem, but we can’t live with the second. Licensing is a pest.
While we’re at it, we should be able to leverage JNA and fix the first problem too. In the end we could end up with a very nice library that lots of people use.
The Oshi Project
Introducing the Oshi Project. I’ve put a day of work into it and a bit of design thought in terms of operating system and hardware interfaces. I’ve implemented those for Windows, so it can generate this kind of output.
Microsoft Windows 7
2 CPU(s):
Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz
Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz
Memory: 532.1 MB/2.0 GB
Here’s the code for the above.
What’s Next?
Oshi needs your help to implement *nix ports and create interfaces for other types of software and hardware information, such as disks, processes, printers, etc. Some of the functionality may be generic and should be pushed into JNA.