Solved

java.lang.ClassNotFound Exception error

Posted on 1998-12-21
6
518 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

628 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