Using a JMX client one can connect to a container Server MBeans and get information very easily. On this blog I have wrote about Jconsole and JvisualVM.
ObjectName memoryMXBean = new ObjectName("java.lang:type=Memory");
You may need to add the credentials for connection and using a map this can be done quick straightforward:
credentials = "admin"; credentials = "admin"; map.put(JMXConnector.CREDENTIALS, credentials); // passing server credentials JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, map);
Silly mistakes to avoid:
Congratulations you forgot the `.java` part – there is nothing my sully than that:
$ javac -classpath .:$$JBOSS_HOME/bin/client/jboss-client.jar jmxTesterror: Class names, 'jmxTest', are only accepted if annotation processing is explicitly requested 1 error