title: How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
body: <p>I've written this java application to respond the data from the command line  and store it into a database :</p>
  
  <pre><code> import java.util.Scanner;
  import java.sql.*;
  
  
  public class Program {
  
  
      public static void main(String[] args)throws ClassNotFoundException 
  
  
      {
  
  
          Connection conn=null;
  
          try {
  
              Class.forName("com.mysql.jdbc.Driver");
  
               conn = DriverManager.getConnection("jdbc:mysql://localhost/DevOps_DB","root","root");
  
  
               PreparedStatement st = conn.prepareStatement("INSERT INTO pers " + "VALUES ('"+args[0]+"'); ");
               st.executeUpdate();
  
  
          } 
  
  
  
          catch (SQLException ex) {
  
              System.out.println("SQL Exception : "+ ex.getMessage());
  
              System.out.println("Vendor Error : "+ ex.getErrorCode());
  
          }
  
  
          catch(ClassNotFoundException ex) {
  
              ex.printStackTrace();
  
  
          }
  
  
  
  //      
  //      for(String arg : args)            
  //      {   
  //           System.out.println(arg);            
  //      }
  
  
  
  
      }
  
  
  
  
  
  }
  </code></pre>
  
  <p>But I've got the following exception :</p>
  
  <pre><code>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
      at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:190)
      at Program.main(Program.java:18)
  </code></pre>
  
  <p>why ? ... any help to fix the problem ?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>I added the .jar file , see the following image :</p>
  
  <p><img src="https://i.stack.imgur.com/8F1ja.png" alt="enter image description here"></p>