aspose file tools*
The moose likes Java in General 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 » Java » Java in General
Bookmark "Class.forName()" Watch "Class.forName()" New topic
Author

Class.forName()

Natraj Gudla
Ranch Hand

Joined: Feb 09, 2003
Posts: 34
Hi,
When i call Class.forName("drivername"),Here where does java pick up the class name from , is it by default the current directory , or does it search it in the classpath?.
and i have a problem that a user will give me the path to the driver and the driver name from the GUI in an application and i have to get the connection to the database using the driver...In this case how do i load the driver when i come to know abt the location of the driver at runtime?.
can any one help me?.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

When i call Class.forName("drivername"),Here where does java pick up the class name from , is it by default the current directory , or does it search it in the classpath?.

It looks in the class path.
and i have a problem that a user will give me the path to the driver and the driver name from the GUI in an application and i have to get the connection to the database using the driver...In this case how do i load the driver when i come to know abt the location of the driver at runtime?.

The simplest way to do this would probably be to write a custom class loader which lets you extend the classpath at runtime.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class.forName()