[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 536
  • Last Modified:

java.lang.ClassNotFound Exception error

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
jmoni
Asked:
jmoni
1 Solution
 
JPlachyCommented:
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
 
evijayCommented:
Please include
oraclejdbc\thin\lib\classes111.zip in your CLASSPATH.

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

Regards
vijay

0
 
heyhey_Commented:
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!

 
jmoniAuthor Commented:
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
 
evijayCommented:
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
 
vertidigerCommented:
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

Independent Software Vendors: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now