File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Reg:Graphs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Reg:Graphs" Watch "Reg:Graphs" New topic
Author

Reg:Graphs

adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Hi,
I want to make an application which can show the cpu usage(for example the taskmanager's performance tab shows in windows xp). How can i do this please some one suggest.
Thanks and Regards
Alexander
Abhijeet Ravankar
Ranch Hand

Joined: Mar 15, 2009
Posts: 62
1. First of all, how will you calculate the cpu usage in Java? I think that it is not possible in pure java (please correct me if I am wrong). The only solution seems to write the cpu-calculating task in C language and use JNI to get the result.

2. If you are able to calculate cpu usage in Java (teach me too then you can run two separate threads. One to display the bars showing percentage (in AWT/Swing) continuously, and the thread other to calculate cpu-usage.

adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Thanks for replying so soon abhijeet. But is not clear to me, this is not the solution. Java is so widely used there may be at least one technique to solve it.
Abhijeet Ravankar
Ranch Hand

Joined: Mar 15, 2009
Posts: 62
I am not sure if Java 1.6 has any API to calculate cpu usage. Try the following link which teaches how to calculate cpu usage using JNI with C code.

http://www.javaworld.com/javaworld/javaqa/2002-11/01-qa-1108-cpu.html

Once you have the cpu usage, drawing a simple rectangular bar (3D) is easy in multithreading.



pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
adeeb alexander wrote:Thanks for replying so soon abhijeet. But is not clear to me, this is not the solution. Java is so widely used there may be at least one technique to solve it.

But what is Java mainly used for? For apps that can be used on a wide variety of hardware and OS platforms. This forces Java to be as far removed from the hardware as possible, making it, in my opinion, a poor choice for this type of applciation.
adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Thanks for helping.
Now just think that i have some thousand x axis y axis values respec. how can i generate a continuous graph using those values.

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

Check out JFree Chart
Their demo comes with a jvm memory usage graph which is very similar to what you require.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reg:Graphs
 
Similar Threads
Idle's mind is a devils workshop
Testing
May 31, 2001 - test Job Offer $xxx,xxx Colorado Springs
No Banner for JSF book promo?
Brain Teasers