Getting a list of all Java classes used from all JVMs?

I want to have a list of all classes that are loaded on multiple threads / JVM at a particular point in time.

I know that when running java with a parameter, -verbose

you can write it to a file something like this:java -verbose:class com.package.Foo > classes-used.txt

However, I have threads in my main program that use a shell script to start a new jar. I wish I didn't have to write a parameter -verbose

in every shell script, and I'm wondering if there is another way to do this in Linux?

+2


source to share


1 answer


You can use the jcmd command that comes with the JDK. This does not require any special arguments to be sent to the JVM at startup.

jcmd 

      

Will list all running JVMs as well as their pid (process id).



jcmd <pid> GC.class_histogram

      

then it will list each class that is currently loaded in this JVM, along with the number of instances.

+6


source







All Articles