Standard MBean

MBeanServer mbs = ...
             something...;
ObjectName name =
    new ObjectName("com.example:type=Memory");
              MemoryUsage memoryUsage =  
             (MemoryUsage)
     mbs.getAttribute(name, "MemoryUsage");
long used = memoryUsage.
             getUsed();</td>
          
 

MXBean

MBeanServer mbs = ...
             something...;
ObjectName name =
    new ObjectName("com.example:type=Memory");
              CompositeData memoryUsage =  
             (CompositeData)
     mbs.getAttribute(name, "MemoryUsage");
long used =  
             (Long) memoryUsage.
             get("Used");