When I set out to port .NET application from windows 7 to Linux, I thought its going to be a long laborious process with lots of configurations. But surprisingly it did not take much time. Most of you might have already heard about mono-project, an open source implementation of the Microsoft .NET Framework. It is aimed at helping developers develop cross-platform applications.
This is a no brainer approach for getting CPU and Memory usage of the running processes under Linux. All we do is execute Linux shell commands programmatically in Java and extract its output. I had to use this when I was developing a monitoring software for Linux. Of course there are lots of libraries available to accomplish this and I ended up using them as well to complete my project. One such library is Sigar Api. Well, if you are forced to do it the crude way, you can use code below. However, it also is a good introduction for executing Linux commands from Java if you haven't done it already.