Link to home
Start Free TrialLog in
Avatar of gingermeatboy
gingermeatboy

asked on

finding CPU?

Is it possible to find the CPU usage of a machine using Java (preferably without me having to learn to use JNI!) it would obviously need to be platform independent, I can't see anything in the API, just properties to find out memory, OS etc

All help appreciated greatly
Avatar of Venci75
Venci75

no - you will have to use JNI
i agree, you will have to use JNI, but it's so easy
ASKER CERTIFIED SOLUTION
Avatar of ReTsam
ReTsam

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Resources

Download the complete library that accompanies this article:
http://www.javaworld.com/javaworld/javaqa/2002-11/cpu/01-qa-1108-cpu.zip 

JNI specification and tutorials:
http://java.sun.com/j2se/1.4/docs/guide/jni/index.html 

For a good overview of JNI, see Stuart Dabbs Halloway's Component Development for the Java Platform (Addison-Wesley, December 2001; ISBN: 0201753065):
http://www.amazon.com/exec/obidos/ASIN/0201753065/javaworld 

In "Java Tip 92: Use the JVM Profiler Interface for Accurate Timing," Jesper Gortz explores an alternative direction for profiling CPU usage. (However, using JVMPI requires more work to compute CPU usage for the entire process compared to this article's solution):
http://www.javaworld.com/javaworld/javatips/jw-javatip92.html 

See the Java Q&A index page for the full Q&A catalog:
http://www.javaworld.com/columns/jw-qna-index.shtml 

For more than 100 insightful Java tips, visit JavaWorld's Java Tips index page:
http://www.javaworld.com/columns/jw-tips-index.shtml 

Browse the Core Java section of JavaWorld's Topical Index:
http://www.javaworld.com/channel_content/jw-core-index.shtml 

Get more of your questions answered in our Java Beginner discussion:
http://forums.devworld.com/webx?50@@.ee6b804 

Sign up for JavaWorld's free weekly email newsletters:
http://www.javaworld.com/subscribe 

You'll find a wealth of IT-related articles from our sister publications at IDG.net
Avatar of gingermeatboy

ASKER

Thanks very much for your help, hopefully I can get this part of my program working now!