This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Class.forname Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Class.forname" Watch "Class.forname" New topic
Author

Class.forname

Mini Ramachandran
Greenhorn

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)?
Class.forname("className").newInstance();
getClass().getName() gets the name of the class loaded.
Thanks.
Peter den Haan
author
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: http://aspose.com/file-tools
 
subject: Class.forname