File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes class.forname...working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "class.forname...working" Watch "class.forname...working" New topic


Kunal Choudhary

Joined: Feb 25, 2009
Posts: 14
can anybody please explain the actual working of the class.forname() method....esp with reference to the memory.....the concepts....also what happens when i say "class.forname(oracle.jdbc.driver);".....what happens internally
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
The JVM (probably a ClassLoader) finds the class of that name and loads a Class<T> object into the memory used by the JVM. In the case of the JDBC connector classes, I believe there is a static initialiser block which initiates the connection to the database.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Whenever a class gets loaded, all of its static variables get initialized and static initializer blocks get fired. You know, 'static' applies on the class itself and has no instance dependence.
I agree. Here's the link:
subject: class.forname...working
It's not a secret anymore!