Home > Java > javaTutorial > body text

How to List All Classes in a Specific Package, Loaded or Not, in the JVM?

DDD
Release: 2024-10-26 05:38:02
Original
386 people have browsed it

How to List All Classes in a Specific Package, Loaded or Not, in the JVM?

Get 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 ....
Copy after login

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]
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!