Skip to content

Instantly share code, notes, and snippets.

@scottmarlow
Created February 10, 2012 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottmarlow/1792265 to your computer and use it in GitHub Desktop.
Save scottmarlow/1792265 to your computer and use it in GitHub Desktop.
public class test1 {
public static void main(String args[]) {
final String host = "localhost";
final int newPort = 9999;
String s = "service:jmx:remoting-jmx:///" + host + ":"+ newPort;
if (args.length > 1) {
s = args[1];
}
try {
System.out.println("Connecting to: " + s);
javax.management.remote.JMXServiceURL url = new javax.management.remote.JMXServiceURL(s);
javax.management.remote.JMXConnector conn = javax.management.remote.JMXConnectorFactory.connect(url, null);
System.out.println("JMXConnectorFactory.connect(" + url +",null) returned connection = "+conn);
} catch(Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment