0

I created a program in java and I want to know its CPU usage when it is being run. Is there any function? Can you help me please?

Thank you in advance!

  • 2
    http://stackoverflow.com/questions/47177/how-to-monitor-the-computers-cpu-memory-and-disk-usage-in-java – TypeIA Dec 12 '13 at 22:50

4 Answers4

2

Use the tools in your operating system, say: in Windows you can see this information in the task manager, or in Linux use the top command.

Óscar López
  • 232,561
  • 37
  • 312
  • 386
0

I would suggest running jconsole, it will give you these statistics for all currently running Java applications. It can be found in the bin directory of your Java installation.

drembert
  • 1,246
  • 1
  • 9
  • 18
0

This might be useful. The link will take you to an older post with a similar problem.

Community
  • 1
  • 1
Aaron Ausmus
  • 53
  • 1
  • 1
  • 6
  • This should be a comment, not an answer – Óscar López Dec 12 '13 at 22:54
  • 1
    Sorry... what's the difference? I'm relatively new to SO – Aaron Ausmus Dec 12 '13 at 22:55
  • An answer contains a solution to the problem. Anything else should be a comment. – JBentley Dec 12 '13 at 22:56
  • Providing a link is not really an answer, it should be posted as a comment in the question. Now if you add some additional information, an explanation, or some code, then that should be posted as an answer. As it is, this answer is risking getting downvoted (not by me, but who knows if someone else decides to do it?) – Óscar López Dec 12 '13 at 22:57
  • Until he hits 50 reputation, he cannot just leave comments. – SimplyPanda Dec 12 '13 at 22:59
  • @SimplyPanda That doesn't change anything. Answers should not be used to circumvent the 50 reputation requirement for comments (I'm not saying the answerer deliberately did that in this case however). – JBentley Dec 12 '13 at 23:02
  • @JBentley Never said he should leave answers. Merely pointing out he is incapable of leaving comments. – SimplyPanda Dec 12 '13 at 23:04
0

Use the tool that comes with the java SDK called VisualVM. It can show you much much more than just CPU usage, in real time.

Saša Šijak
  • 8,717
  • 5
  • 47
  • 82