private static JMXConnector connect ( String host , String port , String login , String password ) throws IOException { // Set the service URL. JMXServiceURL serviceUrl = new JMXServiceURL ( new StringBuffer ( ) . append ( "service:jmx:rmi://" ) . append ( host ) . append ( ":" ) . append ( port ) . append ( "/jndi/rmi://" ) . append ( host ) . append ( ":" ) . append ( port ) . append ( "/jmxrmi" ) . toString ( ) ) ; // Set the service environment. Map < String , Object > serviceEnv = new HashMap < String , Object > ( ) ; serviceEnv . put ( "jmx.remote.credentials" , new String [ ] { login , password } ) ; // Connect to the JMX service. return JMXConnectorFactory . connect ( serviceUrl , serviceEnv ) ; }
Connect to the JMX service .