i want to get the list of all the objects(user defined class and predefined class that are being used in my program. can anyone help me out how to do that??
The best way to achieve this would be to run your app through a profiler. Unfortunately, I am not a permanent resident (or even a visitor :-)) of the Java world, so I can't suggest to you the best tool. However, a quick search on your favorite search engine for "java profiler" yields a page that lists bunch of open source profilers.
Hope that helps.
If you specify -verbose:class
, information about each class loaded will be written to stdout.
Profiling or using the verbose
flag are good ideas. But if you need to get these results programatically you'll need a different approach.
The only way as I see it, and this is really overkilling it, is to write your own class loader - simply inherit the basic class loader - and extend it so that it saves all classes loaded in a list or whatever.
Note that this is really going to heavy on performance, and make sure you double check if you really need this.
If not programatically, just use the other methods mentioned.