• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

java -verbose:class command

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i use java -verbose:class command to run a class file, why is it that some classes not being mentioned in the import statements and not used in the .java file are getting loaded? Or is it that all the class files present in the jar(rt.jar in this case) would be loaded no matter what all classes are being used in the java program ?
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A few classes are used by the JVM itself and are always loaded; those classes depend on a few others, which are thus also loaded. These include things like Object, System, Thread, String, Class, Cloneable, Serializable, Comparable, Throwable, Exception, Error, RuntimeException, etc, etc.

Then there are the classes that your class uses, and the classes that these other classes depend on... this can turn out to be quite a few classes altogether. Things like PrintStream, and and many classes that it relies on from java.io.

In any case, no, Java doesn't load everything in rt.jar, only the classes that are needed. Loading every single class in rt.jar would take quite a long time!
 
reply
    Bookmark Topic Watch Topic
  • New Topic