• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reg:Graphs

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic