I compiled my java project in netbeans this is my connection function:
public void connection() {
    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:", "", "");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
(i removed the username and password)
and after i compiled and run jar file i got error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
It is important to note that in my classpath there is the mysql-connector-java-5.1.38-bin.jar jar libary
and i compiled it in netbeans. (actually in eclipse after compiled the jar file open successfully without errors...)
tnx a lot
 
     
     
    