question: public static void startLocalJMXServer ( final int port , final AllowConnections allowConnections ) throws IOException , MalformedURLException , RemoteException { final RMISocketFactory serverSocketFactory = allowConnections == AllowConnections . ALL ? RMISocketFactory . getDefaultSocketFactory ( ) : new LocalhostRMIServerSocketFactory ( ) ; LocateRegistry . createRegistry ( port , RMISocketFactory . getDefaultSocketFactory ( ) , serverSocketFactory ) ; final MBeanServer mbs = ManagementFactory . getPlatformMBeanServer ( ) ; final JMXServiceURL url = new JMXServiceURL ( "service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi" ) ; final JMXConnectorServer rmiServer = JMXConnectorServerFactory . newJMXConnectorServer ( url , null , mbs ) ; rmiServer . start ( ) ; }
target:  Programmatically starts a JMX server.