Solved

java.lang.ClassNotFound Exception error

Posted on 1998-12-21
6
500 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Updating Java 9 87
where is session ID cache stored 1 39
groovy example issue 10 67
Groovy:unable to resolve class error 2 31
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

758 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

19 Experts available now in Live!

Get 1:1 Help Now