As the name suggests classNotFoundException in Java occurs when JVM (Java Virtual Machine) tries to load a particular class and doesn't found the requested class in the classpath you specified. When building the project, java throws ClassNotFoundException exception because a file (the com.mysql.jdbc.Driver class) from the java mysql connectivity library is not found. The solution is adding the library to the project, and java will find the com.mysql.jdbc.Driver