Java verbose class loading

亡梦爱人 提交于 2019-11-27 06:52:29
nwinkler

I guess your best bet is to do the following:

  • Output some fixed text once your main method starts and right before it ends.
  • Pipe the verbose output into a file
  • Use things like less or grep to find the classes loaded between the two tags from the main method.

There's a similar question and some answers here: Is there a way to get which classes a ClassLoader has loaded?

Did you try -verbose:class?

Here's a sed expression that will parse the output of java -verbose:class to produce pairs of loaded class name and its jar file. You can further pipe through a sort to get unique jar files. For example,

java -verbose:class -version 2>/dev/null |
  sed -ne 's/\[Loaded \(.\+\) from \(.\+\)\]/\2/p' | 
  sort -u

outputs

/usr/local/jdk1.7.0_67/jre/lib/rt.jar
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!