code: public boolean unregisterMBean(String name) throws MBeanRegistrationException {
  
          synchronized (mBeanServer) {
  
              ObjectName toRemoveName;
  
              try {
                  toRemoveName = new ObjectName(name);
              } catch (MalformedObjectNameException e) {
                  return false; // bean with malformed can not be registered.
              }
  
              beansNames.remove(toRemoveName);
  
              try {
                  mBeanServer.unregisterMBean(toRemoveName);
                  return true;
              } catch (InstanceNotFoundException e) {
                  return false;
              }
  
          }
  
      }
docs: Unregisters MBean from platform MBean server.
  @param name name of MBean to unregister
  @return true - bean unregistered
  false - bean with such name not found
  @throws MBeanRegistrationException thrown by MBeanServer