Solved

java.lang.ClassNotFound Exception error

Posted on 1998-12-21
6
503 Views
Last Modified: 2012-06-27
What would cause the classNotFound Exception error? Using Orcale7.3, JDK1.2.3 and oracle7 JDBC driver. Followed all the instructions for installations and set my classpath.
When I run the JdbcCheckup example provided I get this error:

java.lang.ClassNotFound Exception : oracle/jdbc/driver/OracleDriver
at java.lang.Class.forName(Native Method)

But it compiles without problem.

Many thanks for your help.

Jake
0
Comment
Question by:jmoni
6 Comments
 

Expert Comment

by:JPlachy
ID: 1229919
Hi,
the problem is not the javacode, as you wrote your classpath
seems to be OK in this situation, but your PATH not,
or at least your ORACLE JDBC-support DLL is not found.

'native Method' means that the function is implemented
in another language, and that it will be imported at runtime from a provided DLL.

But I cant tell which DLL is not found and I dont know where it should be placed

I hope this helps !



 
0
 
LVL 4

Expert Comment

by:evijay
ID: 1229920
Please include
oraclejdbc\thin\lib\classes111.zip in your CLASSPATH.

set CLASSPATH=%CLASSPATH%;c:\oraclejdbc\thin\lib\classes111.zip

Regards
vijay

0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1229921
JPlachy:
missing class is quite sure a Java class - and that is the class that implements the real Oracle JDBC driver. it's name is
"oracle.jdbc.driver.OracleDriver.class"

Jake:
it compiles without problems, because you your compiler does not uses this class - it is loaded at run time from this line
Class.forName("oracle.jdbc.driver.OracleDriver.class");
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:jmoni
ID: 1229922
vijay,

Thanks for your effort but the zip files are in c:\jdbc There is no directory with this path c:\orcalejdbc\thin\lib\classes111.zip.

I thought this was suppose to be straight forward. Where is this class "oracle.jdbc.driver.OracleDriver" located?

Thanks

Jake
0
 
LVL 4

Expert Comment

by:evijay
ID: 1229923
There will be somewhere in c:\jdbc directory, some zip files. Include the full path names of each of the zip files in the classpath. I just gave an example in my answer.

Vijay
0
 

Accepted Solution

by:
vertidiger earned 50 total points
ID: 1229924
Jake -

  evijay's answer was correct, you must add the classes111.zip file to your class path.
Your program will compile because it will not attempt to create an instance of the
oracle.jdbc.driver.OracleDriver until run time.  

   Here's some details straight from my working set up:
Java Code:
    try
    {
      Class.forName("oracle.jdbc.driver.OracleDriver");
    }
    catch(ClassNotFoundException  ex)
    {
      ex.printStackTrace();
      System.out.println("Sorry Jake, classes111.zip is still not found in classpath.");
    }
Classpath:
   On Windows:
      from dos:
           C:\>set ClassPath=%ClassPath%;C:\jdbc\lib\classes111.zip
           C:\>echo %ClassPath%
      or in autoexec.bat file:
           set ClassPath=%ClassPath%;C:\jdbc\lib\classes111.zip
    On Unix(Linux):
        in .bashrc (or whatever shell you're using)
           export CLASSPATH=$CLASSPATH:/home/jake/jdbc/lib/classes111.zip
        from commandline:
            #->export CLASSPATH=$CLASSPATH:/home/jake/jdbc/lib/classes111.zip
            #->echo $CLASSPATH

In both cases echo is not necessary, and just prints out the classpath so that you
can verify that the path to the zip file was added correctly. You'll want to change the
directory in the commands to match where it is on your disk. You may want to move
the classes111.zip file into the lib directory in your jdk folder. That will make it easier
to find and make your classpath easier to maintain.

oracle.jdbc.driver.OracleDriver is located inside the zip file.  If you look at the
reference material on java packages you will find the details.  If you were to
unzip the classes111.zip file you would find that inside a folder called oracle
there was a folder called jdbc and inside that folder there was another folder
called driver and finally, inside the driver folder there was a class file called
OracleDriver.class.  Java knows how to find the class inside the zip file,
you just need to tell java where the class file is.  You do not want leave
the unziped classes111.zip file on your system if you unzip it.  That can
cause problems for java when it attempts to find the class.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 75
Java asynchronous logging 4 50
DO we need Java installed on a Windows PC and WHY ? 13 95
diffSum example 4 20
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now