File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does it mean when the class is loaded to JVM?

 
Hanna Habashy
Ranch Hand
Posts: 532
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
I know it is not a very smart quistion, but I got a little confused.
I want to know what does it mean for a class to be loaded to the JVM. I mean when exactly??
Is it when the class is instanciated, or compiled..??
Thanks
 
Jeff Bosch
Ranch Hand
Posts: 805
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Hanna -
Classes can't be loaded by the JVM at compile time because the compiler and the JVM are separate programs. You compile your source-code text file into one or more bytecode class files using "javac". Then, you invoke the JVM with "java".
The class that you invoke when you run java SomeClass gets loaded first, and the JVM looks for a main() method for starting the program. Other classes are loaded or even pre-loaded (cached) depending on the JVM implementation, which you can influence by writing your own class loaders. Chapter 12 of the Java Language Specification, available for free download from Sun, contains all the gory details and references to the Java Virtual Machine Specification if you crave even more binary gore.
Cheers,
Jeff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic