• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 24207
46
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic