Get a listing of all currently loaded classes in a given JVM instance
Asked Answered
I

3

8

It'd be handy to know which classes are currently loaded by a given JVM instance.

Is there some way to get them through JVisualVM, for instance?

Edit: I'm aware of the solution given @ Java - Get a list of all Classes loaded in the JVM, yet I'd like to know if there's a way to do that through JVisualVM or some other tool. At the moment I'm working against a RCP application, and I'd prefer to not having to run the application through the java tool (I'm lazy, yes).

Invade answered 15/5, 2013 at 7:41 Comment(2)
Possible duplicate of Java - Get a list of all Classes loaded in the JVMSabu
Try YourKit Profiler: yourkit.com/docs/java/help/classloading.jsp . There is a trial version that you can give a shot.Paneling
C
1

You specifically mentioned using a tool to get this information, so I assume you were interested in non-programmatic solution. jcmd seems to be a good way to do just that.

This was already addressed in https://mcmap.net/q/238363/-get-a-list-of-all-classes-loaded-in-the-jvm but I wanted to add another subcommand.

jcmd <jvm_pid> VM.class_hierarchy (previously mentioned)

jcmd <jvm_pid> VM.classloaders show-classes

Cerebrospinal answered 2/12, 2023 at 8:35 Comment(0)
N
0

Did you try jconsole?

Jconsole should be able to display list of loaded classes, see jConsole Documentation.

See the Viewing Overview Information section, the screenshot shows number of loaded classes. Plus, you can see a tab called Classes, this is where the class loading info is.

Nucleoprotein answered 15/5, 2013 at 23:34 Comment(2)
It seems to inform me about the class count, not which classes correspond to which classloaders. Am I wrong?Invade
Opps, you are correct. I did use see this feature somewhere though, will post an update once I find it.Vlada
A
0

You can do this with VisualVM:

  1. $JAVA_HOME/bin/jvisialvm
  2. Select your jvm app -> Sampler -> Memory -> click "Heap Dump"
  3. Open created Heap dump -> click "Classes". Where is a search field at bottom.

Your are welcome.

Aerophobia answered 31/10, 2018 at 17:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.