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


Mini Ramachandran

Joined: Jan 11, 2001
Posts: 17
How do I get the name of the "className" initialized here from another class (both in the same package)?
getClass().getName() gets the name of the class loaded.
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Not sure what exactly you are asking... but are you looking for the class literal? TheClass.class.getName() will return "your.package.TheClass" and will instantiate TheClass if passed as argument to Class.forName().
- Peter
I agree. Here's the link:
subject: Class.forname
It's not a secret anymore!