• 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
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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.
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic