title: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
body: <p>I wrote a Java Servlet program but when I run it, it was showing the Exception </p>
  
  <pre><code>java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
  </code></pre>
  
  <p>My code is</p>
  
  <pre><code>package skypark;
  
  import java.io.*;
  import javax.servlet.*;
  import java.text.*;
  import javax.servlet.http.*;
  import java.sql.*;
  import java.sql.Date;
  
  public class Registration extends HttpServlet {
  
      private static final long serialVersionUID = 1L;
  
      public static Connection prepareConnection() throws ClassNotFoundException, SQLException {
          String dcn = "oracle.jdbc.driver.OracleDriver";
          String url = "jdbc:oracle:thin:@JamesPJ-PC:1521:skypark";
          String usname = "system";
          String pass = "tiger";
          Class.forName(dcn);
          return DriverManager.getConnection(url, usname, pass);
      }
  
      public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          resp.setContentType("text/html");
          PrintWriter out = resp.getWriter();
  
          try {
              String phone1, dofb, date1, month, year, uname, fname, lname, address, city, state, country;
              String pin, email, password, gender, lang, qual, relegion, privacy, hobbies, fav;
  
              uname = req.getParameter("uname");
              fname = req.getParameter("fname");
              lname = req.getParameter("lname");
              date1 = req.getParameter("date");
              month = req.getParameter("month");
              year = req.getParameter("year");
              address = req.getParameter("address");
              city = req.getParameter("city");
              state = req.getParameter("state");
              country = req.getParameter("country");
              pin = req.getParameter("pin");
              email = req.getParameter("email");
              password = req.getParameter("password");
              gender = req.getParameter("gender");
              phone1 = req.getParameter("phone");
  
              lang = "";
              qual = "";
              relegion = "";
              privacy = "";
              hobbies = "";
              fav = "";
  
              dofb = date1 + "-" + month + "-" + year;
              int phone = Integer.parseInt(phone1);
              DateFormat formatter;
              java.util.Date dob;
              formatter = new SimpleDateFormat("dd-MM-yy");
              dob = formatter.parse(dofb);
  
              Connection con = prepareConnection();
              String Query = "Insert into regdetails values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
              PreparedStatement ps = con.prepareStatement(Query);
  
              ps.setString(1, uname);
              ps.setString(2, fname);
              ps.setString(3, lname);
              ps.setDate(4, (Date) dob);
              ps.setString(5, address);
              ps.setString(6, city);
              ps.setString(7, state);
              ps.setString(8, country);
              ps.setString(9, pin);
              ps.setString(10, lang);
              ps.setString(11, qual);
              ps.setString(12, relegion);
              ps.setString(13, privacy);
              ps.setString(14, hobbies);
              ps.setString(15, fav);
              ps.setString(16, gender);
  
              int c = ps.executeUpdate();
  
              String query = "insert into passmanager values(?,?,?,?)";
              PreparedStatement ps1 = con.prepareStatement(query);
  
              ps1.setString(1, uname);
              ps1.setString(2, password);
              ps1.setString(3, email);
              ps1.setInt(4, phone);
  
              int i = ps1.executeUpdate();
  
              if (c == 1 || c == Statement.SUCCESS_NO_INFO &amp;&amp; i == 1 || i == Statement.SUCCESS_NO_INFO) {
                  out.println("&lt;html&gt;&lt;head&gt;&lt;title&gt;Login&lt;/title&gt;&lt;/head&gt;&lt;body&gt;");
                  out.println("&lt;center&gt;&lt;h2&gt;Skypark.com&lt;/h2&gt;");
                  out.println("&lt;table border=0&gt;&lt;tr&gt;");
                  out.println("&lt;td&gt;UserName/E-Mail&lt;/td&gt;");
                  out.println("&lt;form action=login method=post");
                  out.println("&lt;td&gt;&lt;input type=text name=uname&gt;&lt;/td&gt;");
                  out.println("&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Password&lt;/td&gt;");
                  out.println("&lt;td&gt;&lt;input type=password name=pass&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;");
                  out.println("&lt;input type=submit value=Login&gt;");
                  out.println("&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;");
              } else {
                  out.println("&lt;html&gt;&lt;head&gt;&lt;title&gt;Error!&lt;/title&gt;&lt;/head&gt;&lt;body&gt;");
                  out.println("&lt;center&gt;&lt;b&gt;Given details are incorrect&lt;/b&gt;");
                  out.println(" Please try again&lt;/center&gt;&lt;/body&gt;&lt;/html&gt;");
                  RequestDispatcher rd = req.getRequestDispatcher("registration.html");
                  rd.include(req, resp);
                  return;
              }
          } catch (ClassNotFoundException cnfe) {
              out.println("&lt;html&gt;&lt;head&gt;&lt;title&gt;Error!&lt;/title&gt;&lt;body&gt;");
              out.println("&lt;b&gt;&lt;i&gt;Class not found " + cnfe + "&lt;/i&gt;&lt;/b&gt;");
              out.println("&lt;/body&gt;&lt;/html&gt;");
          } catch (SQLException sqle) {
              out.println("&lt;html&gt;&lt;head&gt;&lt;title&gt;Error!&lt;/title&gt;&lt;body&gt;");
              out.println("&lt;b&gt;&lt;i&gt;Unable to process try after some time Sql error&lt;/i&gt;&lt;/b&gt;");
              out.println("&lt;/body&gt;&lt;/html&gt;");
          } catch (ParseException e) {
              out.println("&lt;html&gt;&lt;head&gt;&lt;title&gt;Error!&lt;/title&gt;&lt;body&gt;");
              out.println("&lt;b&gt;&lt;i&gt;Unable to process Parseint exc " + e + "&lt;/i&gt;&lt;/b&gt;");
              out.println("&lt;/body&gt;&lt;/html&gt;");
          }
  
          out.flush();
          out.close();
      }
  }
  </code></pre>
  
  <p>My class path is :</p>
  
  <pre><code>C: \Windows\ system32 &gt; echo % classpath %
    E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ oui\ jlib\ classes12.jar;
  E: \app\ JamesPJ\ product 11.2.0\ dbhome_1\ jlib\ orai18n.jar;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ jdbc\ lib\ ojdc6_g.jar;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ BIN;
  C: \Program Files\ Java\ jdk1.7.0_09\ bin;
  C: \Users\ JamesPJ\ Documents;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ jdbc\ lib;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ jlib;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ jdbc\ lib\ ojdbc6.jar;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ oc4j\ jdbc\ lib\ orai18n.jar;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ oc4j\ jdbc\ lib\ ocrs12.jar;
  E: \app\ JamesPJ\ product\ 11.2.0\ dbhome_1\ owb\ wf\ lib\ ojdbc14.jar;
  C: \Program Files\ Apache Software Foundation\ Tomcat 7.0\ lib\ servlet - api.jar
  </code></pre>
  
  <p>When I give the</p>
  
  <pre><code> java oracle.jdbc.driver.OracleDriver 
  </code></pre>
  
  <p>command in command prompt, it was showing following lines</p>
  
  <pre><code>Error: Main method not found in class oracle.jdbc.driver.OracleDriver, please define the main method as:
         public static void main(String[] args)
  </code></pre>