I got the metrics from JMX port by using the Nagios agent through curl command here is the syntax.
curl -s -X POST http://${hostname}:${agentport}/p1/kdc/monitor -d " {\"hostname\": \"${hostname}\", \"port\": \"${jmxport}\", \"metric\": \"${metric}\"}"'
curl -s -X POST http://manikya.devops.com/p1/kdc/monitor -d '{"hostname":"manikya.devops.com", "port":"9999", "metric": "bytes_in_per_second"}'
I want the same thing by Java.