Map environment = new HashMap();
String[] credentials = new String[]{username, password};
environment.put(JMXConnector.CREDENTIALS, credentials);
environment.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, BaseDeploymentFactory.class.getClassLoader());
try {
JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+params.getHost()+":"+params.getPort()+"/JMXConnector");
JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
RemoteDeploymentManager manager = getRemoteDeploymentManager();
manager.init(jmxConnector, params.getHost());
if(!manager.isSameMachine()) {
manager.setAuthentication(username, password);