Showing posts from March, 2011

Connecting to JMX with username and password

Got the tip from
echo("\nCreate an RMI connector client and " +
"connect it to the RMI connector server");
JMXServiceURL url =
//new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://");

String[] credentials = new String[2];
// The user will travel as clear text
credentials[0] = "user"; //user name
credentials[1] = "password"; //password

Map environment = new HashMap();

environment.put(JMXConnector.CREDENTIALS, credentials);

JMXConnector jmxc = JMXConnectorFactory.connect(url, environment);