Java Program for finding CPU Utilization
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vikash_Kumar
Posted On:   Thursday, January 11, 2007 12:02 AM

Using java I have to find the CPU utilization. Can someone provide me the coding or any helps. I tried this : import java.io.*; public class CPU { public static void main(String[] args) throws IOException, Exception { Runtime r = Runtime.getRuntime(); r.exec("C:\WINDOWS\System32\CMD.exe /c taskmgr"); } } This works in windows, it opens Task manager, one can see the percentage of CPU utilization, but this is not what I require, I want to print the CPU statistics in command prompt. The program should work for any Operating System (Linux, Windows etc). Thanks in Advance Vikash    More>>

Using java I have to find the CPU utilization. Can someone provide me the coding or any helps.
I tried this :

import java.io.*;
public class CPU {
public static void main(String[] args) throws IOException, Exception {
Runtime r = Runtime.getRuntime();
r.exec("C:\WINDOWS\System32\CMD.exe /c taskmgr");

}

}


This works in windows, it opens Task manager, one can see the percentage of CPU utilization, but this is not what I require, I want to print the CPU statistics in command prompt. The program should work for any Operating System (Linux, Windows etc).

Thanks in Advance
Vikash

   <<Less

Re: Java Program for finding CPU Utilization

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, January 13, 2007 02:50 PM

One thing to consider doing is to use the GNU command-line utilities, which work on all flavors of Unix/Linux etc., and for Windows you can install Cygwin, so they'll work via bash there too.
About | Sitemap | Contact