Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ClassNotFound even though in CLASSPATH

16 views
Skip to first unread message

James Adams

unread,
Jul 28, 1999, 3:00:00 AM7/28/99
to
Hello,

I am having trouble loading the MySQL driver in that I get a message
telling me that the class can't be found, even though the
CLASSPATH variable contains the correct path for finding the driver. To
wit:

the MM-MySQL driver is installed at ~/java/lib/mm.mysql.jdbc-1.0,

% ls -l ~/java/lib/mm.mysql.jdbc-1.0/org/gjt/mm/mysql/Driver.*
-rw-rw-r-- 1 500 misc 3090 Aug 25 1998
/home/james/java/lib/mm.mysql.jdbc-1.0/org/gjt/mm/mysql/Driver.class
-rw-r--r-- 1 500 misc 11115 Aug 25 1998
/home/james/java/lib/mm.mysql.jdbc-1.0/org/gjt/mm/mysql/Driver.java


my CLASSPATH is set up to use that path,

% echo $CLASSPATH
.:~/java/lib/mm.mysql.jdbc-1.0


my code is crashing at the following call:

Class.forName("org.gjt.mm.mysql.Driver");


the error/exception message:

java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:280)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275)

at java.lang.ClassLoader.loadClass(ClassLoader.java:237)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:124)
at database1.main(database1.java:13)


I am using an SGI and Java version 1.2.


Can someone please tell me what I'm doing wrong ? I'm under the
assumption that having the CLASSPATH correctly set up is all that's
needed to avoid a ClassNotFound exception, but obviously I'm missing
something (or I'm not as properly configured as I think).

Thanks in advance !

Alexander Bezprozvanny

unread,
Jul 29, 1999, 3:00:00 AM7/29/99
to
Hi James,

IMHO it is not enough to specify only the directory where your mySQL driver
resides. You have to specify the .jar or .class file for the driver. So your
CLASSPATH shall look like this:

.:~/java/lib/mm.mysql.jdbc-1.0/mysql_uncomp.jar

Of course, you can use
-cp .:~/java/lib/mm.mysql.jdbc-1.0/mysql_uncomp.jar
in the command line while starting JVM.


Hope it will help.

Alexander
----------------------

James Adams

unread,
Jul 29, 1999, 3:00:00 AM7/29/99
to
James Adams wrote:

I replaced ~ with /home/james in my CLASSPATH and all is well now.

-James


0 new messages