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

Class.forName return null

age spets
Ranch Hand

Joined: Aug 07, 2002
Posts: 68
Class.forName("") return with null.
Get this exception:
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(
at dbaseMail.connect(
at MailClientMass.DBConnect30(
at MailClientMass.hentEmail(
at MailClientMass.main(
Anyone that can help me solve this problem?
Ken Robinson
Ranch Hand

Joined: Jul 25, 2002
Posts: 52
Most likely the class you are attempting to load is not in your CLASSPATH.
age spets
Ranch Hand

Joined: Aug 07, 2002
Posts: 68
Is using websphere application developer. The Jar file that include the driver is in the classpath and also in the properties. The weird thing is that other classes in the same project find the driver. Other solutions?
Ken Robinson
Ranch Hand

Joined: Jul 25, 2002
Posts: 52
The fact that you are getting a ClassNotFound exception all but guarentees this is a Classpath problem.
Although you may be able to compile the code, the runtime envionment may be configured differently.
Is this a web app or standalone? The type of app and where you deploy/run has a big effect on what classes are available.
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
To see the classpath that your servlet is actually running under, use System.getProperty("java.class.path"). As Ken suggests, you may find your runtime configuration isn't what you think it is.

"I'm not back." - Bill Harding, Twister

Joined: Sep 18, 2002
Posts: 1
Try importing the following:
import java.lang.Runtime;
import java.sql.*;
import oracle.jdbc.driver.*;
You may go two routes.
Route: 1 - You may put your Driver classes in your Oracle lib and set your classpath like this depending upon your Oracle environment.
Route: 2 - You may put your Driver classes in the lib folder of your App Server and set its classpath.
age spets
Ranch Hand

Joined: Aug 07, 2002
Posts: 68
Thx for the help. It was not in my classpath. This was easy to see when I used the code:
Good tips!
thx all.
Tracey Currier
Ranch Hand

Joined: Feb 06, 2001
Posts: 50
Thank you, this helped me, too.
Using 1.3.1 on IPlanet looking
for a jconnect driver (JDBC driver)

MS,MS,SCJP,SCBCD Seize the day!
I agree. Here's the link:
subject: Class.forName return null
It's not a secret anymore!