title: measure CPU usage of the JVM : java code
body: <p>Is there a way to measure CPU usage of the JVM (once a java application is started) cross platform (windows + unix + mac)?
  I have used Jconsole but what I need is a java code that does this, and not a tool through which I can monitor CPU utilization.
  I have tried out</p>
  
  <pre><code>ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage()
  </code></pre>
  
  <p>using JMX, but it doesn't help since what I need is the specific CPU usage by the JVM (say when I start a server), not the system load average.</p>