1

I'm trying to run a program in java that use mysql connector java to JDBC, the program run in Eclipse but in terminal I get that error

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:375)
    at application.Program.main(Program.java:11)

I am using maven to manage the dependecys but it dont solved my problem

My SO is an archlinux, if its relevant

Andrej Istomin
  • 2,527
  • 2
  • 15
  • 22
  • How are you running the command on the terminal? It looks like maybe the dependencies aren’t included on the classpath. – Tim Moore Oct 11 '22 at 02:15
  • Check that MySQL dependency doesn't have `scope`/`optional` configured. Are you using mvn command to run the application? – Dhaval Gajjar Oct 11 '22 at 03:05
  • Did your jar include all the dependencies ? Seems its not. There should be enough resources and tutorials in internet to resolve this . – Viraj Oct 11 '22 at 03:05

1 Answers1

0

Add mysql-connector jar in classPath or add it in the environment as in environment variable