Standard MBean

MBeanServer mbs = ...
             something...;
ObjectName name =
    new ObjectName("com.example:type=Memory");
Memory
             MBean proxy =
     JMX.
             newMBeanProxy(mbs, name, Memory
             MBean.class);
MemoryUsage memoryUsage = proxy.getMemoryUsage();
Long used = memoryUsage.getUsed();
          
 

MXBean

MBeanServer mbs = ...
             something...;
ObjectName name =
    new ObjectName("com.example:type=Memory");
Memory
             MXBean proxy =
     JMX.
             newMXBeanProxy(mbs, name, Memory
             MXBean.class);
MemoryUsage memoryUsage = proxy.getMemoryUsage();
long used = memoryUsage.getUsed();