Skip to Main Content
  • Questions
  • "java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver"


Question and Answer

Connor McDonald

Thanks for the question, PO-WEN.

Asked: April 21, 2021 - 1:27 pm UTC

Last updated: May 03, 2021 - 4:41 am UTC

Version: RDBMS 12.2.0/ Java jdk and jre 1.8.0_281

Viewed 100+ times

You Asked

May I ask about the "java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver".
Per Java document, the PATH and CLASSPATH shall be configured in the Windows 10 environment variables .

Below are information regarding the system/database version and what I did.

The Java version is as below.
C:\>java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

C:\Program Files\Java\jre\1.8.0_281

C:\Program Files\Java\jdk\1.8.0_281
C:\Program Files\Java\jdk\1.8.0_281\bin
C:\Program Files\Java\jre\1.8.0_281
C:\Program Files\Java\jre\1.8.0_281\bin

The compilation of Java program was successful by using "javac". But the class not found error message was returned during the run time.

I have no problem accessing the Oracle database from Sql*Plus at all. I created two users, created a simple table for the sake of testing.
Everything worked fine. I have no problem with the listener and the TNSNAES.ORA.

Below is the information about database:

SQL*Plus: Release Production on Wed Apr 21 09:08:05 2021

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Enter user-name: c##_chiara
Enter password:
Last Successful login time: Sat Apr 17 2021 09:46:21 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release - 64bit Production

Below is the Java code:
<Begin of the Java Code>

import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

public class Thirdj3 {
public static void main(String[] args){
System.out.println("Beginning of the Thirdj3 program.");

//step1 load the driver class

//step2 create the connection object
Connection con=DriverManager.getConnection(

//step3 create the statement object
Statement stmt=con.createStatement();

//step4 execute query
//*ResultSet rs=stmt.executeQuery("select * from emp");
//*System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));

//step5 close the connection object

catch(Exception e){ System.out.println(e);}

}//End of main
}//End of Thirdj3 Class

<end of the java code>

and we said...

Your CLASSPATH needs to be able to find the jdbc drivers, so something like

set CLASSPATH=%CLASSPATH%;c:\oracle\sqldeveloper\jdbc\lib\ojdbc8.jar

should help (you change to the path to wherever your ojdbc.jar file is)


  (1 rating)


problem solved

Po-Wen Lu, April 28, 2021 - 12:00 pm UTC

Thanks a lot!
It works.

However, I am wondering, all the documents I read indicated only set the "lib" in the classpath where the jar file located without pointing at the specific jar file.

Is there any reason that names the specific jar file is 'required'?


Connor McDonald
May 03, 2021 - 4:41 am UTC

Check the classpath spec

The directory lets you search for classes (not jars), although wildchars are allowed with the correct syntax.