How to List All Classes in a Specific Package, Loaded or Not, in the JVM?
Oct 26, 2024 am 05:38 AMGet a List of All Classes Loaded in the JVM
Question:
How can I obtain a list of all classes, including their children, belonging to a specific package, regardless of whether they are currently loaded in the JVM?
Answer:
While it's not a programmatic solution, you can employ the java command with the -verbose:class flag:
java -verbose:class ....
The JVM will then log the classes it is loading and their sources:
[Opened /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/sunrsasign.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/jsse.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/jce.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/charsets.jar] [Loaded java.lang.Object from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.io.Serializable from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.lang.Comparable from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.lang.CharSequence from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.lang.String from /usr/java/j2sdk1.4.1/jre/lib/rt.jar]
For further information, please refer to the following resource: [Verbose Class Loading](https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/java.html#classloading).
The above is the detailed content of How to List All Classes in a Specific Package, Loaded or Not, in the JVM?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How does Java's classloading mechanism work, including different classloaders and their delegation models?

Top 4 JavaScript Frameworks in 2025: React, Angular, Vue, Svelte

How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?

How can I implement functional programming techniques in Java?

Node.js 20: Key Performance Boosts and New Features

Iceberg: The Future of Data Lake Tables

How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?

How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?
