code: public static void unregister(ObjectName objectName) throws MBeanException {
  
          try {
  
              // Get the MBean server.
              MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
  
              // Check if the MBean is registered with the MBean server.
              if (mBeanServer.isRegistered(objectName)) {
  
                  // Unregister the MBean with the MBean server.
                  mBeanServer.unregisterMBean(objectName);
              }
          } catch (Exception e) {
              throw new MBeanException(e, 
                      "Unable to unregister the MBean " +
                      objectName.getCanonicalName() + ".");
          }
      }
docs: Unregister the MBean represented by the object name.
  
  @param  objectName  the MBean object name.
  
  @throws  MBeanException  if unable to unregister the MBean.