This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg:Graphs

 
adeeb alexander
Ranch Hand
Posts: 268
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 268
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 268
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JFree Chart
Their demo comes with a jvm memory usage graph which is very similar to what you require.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic