{"id":5737,"date":"2024-03-14T03:17:43","date_gmt":"2024-03-14T03:17:43","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/"},"modified":"2025-08-01T19:02:36","modified_gmt":"2025-08-01T19:02:36","slug":"how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/","title":{"rendered":"Get JVM Loaded Classes with JMX"},"content":{"rendered":"<p>You can obtain the names of the classes loaded by the JVM by using the Java Management Extensions (JMX) API. The specific steps are as follows:<\/p>\n<ol>\n<li>Firstly, you need to create a JMX connection to the JVM. This can be achieved using the following code:<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> javax.management.MBeanServerConnection;\r\n<span class=\"hljs-keyword\">import<\/span> javax.management.remote.JMXConnector;\r\n<span class=\"hljs-keyword\">import<\/span> javax.management.remote.JMXConnectorFactory;\r\n<span class=\"hljs-keyword\">import<\/span> javax.management.remote.JMXServiceURL;\r\n\r\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">JMXClient<\/span> {\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title function_\">main<\/span><span class=\"hljs-params\">(String[] args)<\/span> <span class=\"hljs-keyword\">throws<\/span> Exception {\r\n        <span class=\"hljs-type\">JMXServiceURL<\/span> <span class=\"hljs-variable\">url<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">JMXServiceURL<\/span>(<span class=\"hljs-string\">\"service:jmx:rmi:\/\/\/jndi\/rmi:\/\/localhost:1099\/jmxrmi\"<\/span>);\r\n        <span class=\"hljs-type\">JMXConnector<\/span> <span class=\"hljs-variable\">jmxc<\/span> <span class=\"hljs-operator\">=<\/span> JMXConnectorFactory.connect(url, <span class=\"hljs-literal\">null<\/span>);\r\n        <span class=\"hljs-type\">MBeanServerConnection<\/span> <span class=\"hljs-variable\">mbsc<\/span> <span class=\"hljs-operator\">=<\/span> jmxc.getMBeanServerConnection();\r\n        \r\n        <span class=\"hljs-comment\">\/\/ \u8fde\u63a5\u6210\u529f\u540e\u53ef\u4ee5\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c<\/span>\r\n    }\r\n}\r\n<\/code><\/pre>\n<ol>\n<li>Then you can use the MBeanServerConnection object to obtain the names of the loaded classes. The specific code is as follows:<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> javax.management.ObjectName;\r\n\r\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">JMXClient<\/span> {\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title function_\">main<\/span><span class=\"hljs-params\">(String[] args)<\/span> <span class=\"hljs-keyword\">throws<\/span> Exception {\r\n        <span class=\"hljs-comment\">\/\/ \u7701\u7565\u521b\u5efaJMX\u8fde\u63a5\u7684\u4ee3\u7801<\/span>\r\n        \r\n        <span class=\"hljs-type\">ObjectName<\/span> <span class=\"hljs-variable\">classLoadingMBean<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">ObjectName<\/span>(<span class=\"hljs-string\">\"java.lang:type=ClassLoading\"<\/span>);\r\n        <span class=\"hljs-type\">int<\/span> <span class=\"hljs-variable\">loadedClassCount<\/span> <span class=\"hljs-operator\">=<\/span> (<span class=\"hljs-type\">int<\/span>) mbsc.getAttribute(classLoadingMBean, <span class=\"hljs-string\">\"LoadedClassCount\"<\/span>);\r\n\r\n        System.out.println(<span class=\"hljs-string\">\"Loaded class count: \"<\/span> + loadedClassCount);\r\n        \r\n        String[] loadedClassNames = (String[]) mbsc.getAttribute(classLoadingMBean, <span class=\"hljs-string\">\"LoadedClassNames\"<\/span>);\r\n        <span class=\"hljs-keyword\">for<\/span>(String className : loadedClassNames) {\r\n            System.out.println(className);\r\n        }\r\n        \r\n        jmxc.close();\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>By using the above code, you can retrieve the names of classes loaded in the JVM and print them to the console. It is important to note that you need to enable JMX functionality when starting the JVM, and you can refer to the JVM documentation for specific instructions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can obtain the names of the classes loaded by the JVM by using the Java Management Extensions (JMX) API. The specific steps are as follows: Firstly, you need to create a JMX connection to the JVM. This can be achieved using the following code: import javax.management.MBeanServerConnection; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; public class [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[6512,87,279,278,2054],"class_list":["post-5737","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-class-loading","tag-java","tag-java-management-extensions","tag-jmx","tag-jvm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get JVM Loaded Classes with JMX - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Learn how to retrieve JVM loaded class names using JMX API. Step-by-step Java guide with code examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get JVM Loaded Classes with JMX\" \/>\n<meta property=\"og:description\" content=\"Learn how to retrieve JVM loaded class names using JMX API. Step-by-step Java guide with code examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-14T03:17:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-01T19:02:36+00:00\" \/>\n<meta name=\"author\" content=\"Liam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Liam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/\"},\"author\":{\"name\":\"Liam\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671\"},\"headline\":\"Get JVM Loaded Classes with JMX\",\"datePublished\":\"2024-03-14T03:17:43+00:00\",\"dateModified\":\"2025-08-01T19:02:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/\"},\"wordCount\":121,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"keywords\":[\"class loading\",\"Java\",\"Java Management Extensions\",\"JMX\",\"JVM\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/\",\"name\":\"Get JVM Loaded Classes with JMX - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-14T03:17:43+00:00\",\"dateModified\":\"2025-08-01T19:02:36+00:00\",\"description\":\"Learn how to retrieve JVM loaded class names using JMX API. Step-by-step Java guide with code examples.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get JVM Loaded Classes with JMX\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671\",\"name\":\"Liam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g\",\"caption\":\"Liam\"},\"sameAs\":[\"http:\/\/Wilson\"],\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/liamwilson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Get JVM Loaded Classes with JMX - Blog - Silicon Cloud","description":"Learn how to retrieve JVM loaded class names using JMX API. Step-by-step Java guide with code examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/","og_locale":"en_US","og_type":"article","og_title":"Get JVM Loaded Classes with JMX","og_description":"Learn how to retrieve JVM loaded class names using JMX API. Step-by-step Java guide with code examples.","og_url":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-14T03:17:43+00:00","article_modified_time":"2025-08-01T19:02:36+00:00","author":"Liam","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Liam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/"},"author":{"name":"Liam","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671"},"headline":"Get JVM Loaded Classes with JMX","datePublished":"2024-03-14T03:17:43+00:00","dateModified":"2025-08-01T19:02:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/"},"wordCount":121,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"keywords":["class loading","Java","Java Management Extensions","JMX","JVM"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/","url":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/","name":"Get JVM Loaded Classes with JMX - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-14T03:17:43+00:00","dateModified":"2025-08-01T19:02:36+00:00","description":"Learn how to retrieve JVM loaded class names using JMX API. Step-by-step Java guide with code examples.","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/how-to-obtain-the-names-of-classes-that-have-been-loaded-by-the-jvm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Get JVM Loaded Classes with JMX"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671","name":"Liam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g","caption":"Liam"},"sameAs":["http:\/\/Wilson"],"url":"https:\/\/www.silicloud.com\/blog\/author\/liamwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/5737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=5737"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/5737\/revisions"}],"predecessor-version":[{"id":150495,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/5737\/revisions\/150495"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=5737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=5737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=5737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}