• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Class loading

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1)When class will loaded into memory?
-- when program refers class for first time or regardless of that?
-- if it will be loaded regardless of its reference, then how classes are loaded, I mean how class loader comes to know, which classes needs to be loaded.
2)What exactly happens when class is loaded?
3)What is difference between instantiating and loading?

Please help
Thanks in advance
Sandip
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this article out. It is easy to follow and will answer all of your questions:

http://www.digilife.be/quickreferences/PT/Understanding%20the%20Java%20ClassLoader.pdf
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>>1)When class will loaded into memory?
-- when program refers class for first time or regardless of that?
-- if it will be loaded regardless of its reference, then how classes are loaded, I mean how class loader comes to know, which classes needs to be loaded.

JVM has classloader whenever you instantiate JVM by entering "java xyz", JVM classloader will know and load your xyz class because with java you are specifiying class name "xyz".

2)What exactly happens when class is loaded?

When classloader of JVM or user-defined class loader load the class, it will send that class to execution engine of JVM at runtime which executes the bytecode defined in classloader class.

3)What is difference between instantiating and loading?
Once claas is loaded it remains in classloader and whenever you instantiate it, it will call the class file.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic