Jump to content

Intellij java.lang.ClassNotFoundException: com.mysql.jdbc.Driver


Recommended Posts

Posted (edited)

I made a project with Intellij which is not osrs related.

The project use database.

The project works when I run it in Intellij.

However, the runnable JAR (.jar) compiled by IntelliJ shows this error when I run it.

I already added mysql-connector-java-5.1.38-bin.jar to artifact,

and IntelliJ generated mysql-connector-java-5.1.38-bin.jar and the program jar when I click rebuild artifact.

I don't use maven.

 

Could anyone tell me how to solve it step by step?

Edited by Pegasus
Posted
5 minutes ago, Hi G00gle said:

https://stackoverflow.com/questions/23771129/cant-test-connection-to-mysql-using-intellij

 

Are you able to get a connection?

 

A solution might be in there, thought I'd put it in here.

The project works when I run it in intellij.

However, when my pc have low memory or I just don't want to turn on intellij,

I will just want to double click the .jar file, but it shows java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

  • 2 years later...
Posted

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

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...