The first required jar package
The next code is as follows:
Package Com.test;import Java.io.ioexception;import Java.net.malformedurlexception;import java.util.Hashtable; Import Javax.management.mbeanserverconnection;import Javax.management.remote.jmxconnector;import Javax.management.remote.jmxconnectorfactory;import Javax.management.remote.jmxserviceurl;import Javax.naming.context;public class MyConnection {private static jmxconnector connector; Private static final ObjectName service; /* * Instantiate the connection to the Domain Runtime MBean Server. */public static void Initconnection (string hostname, string portstring, string Username, string password) throws I Oexception, malformedurlexception {String protocol = "T3"; Integer Portinteger = integer.valueof (portstring); int port = Portinteger.intvalue (); String jndiroot = "/jndi/"; String mserver = "Weblogic.management.mbeanservers.runtime"; Jmxserviceurl serviceurl = new Jmxserviceurl (protocol, hostname, port, Jndiroot + mserver); Hashtable h = new HashTable (); H.put (Context.security_principal, username); H.put (context.security_credentials, password); H.put (Jmxconnectorfactory.protocol_provider_packages, "weblogic.management.remote"); Connector = Jmxconnectorfactory.connect (serviceurl, h); Connector.getmbeanserverconnection (); public static void Main (string[] args) throws Exception {String hostname = "10.64.34.12"; String portstring = "7001"; String username = "WebLogic"; String password = "Weblogic1"; MyConnection c= New MyConnection (); Initconnection (hostname, portstring, username, password); System.out.print (Connector.tostring ()); Connector.close (); }}
JMX Remote Connection WebLogic