Before down voting my question and say that it's a possible duplicate of another question I want to clear out that I looking for a solution for like 5 hours. I have read all the stackoverflow question related to ClassNotFoundException: com.mysql.cj.jdbc.Driver and none of them fix my issue. As far as I know this simply means that I am missing the mysql connector/j library and I double even triple checked and the library is there included in the project and everything is fine with it. I've been searching over the web for a solution and someone suggested modifying 'C:\xampp\mysql\bin\my.ini file' disabling/commenting out 'skip-networking' and 'skip-federated' and enable/uncomment bind-address="127.0.0.1" . In my file 'skip-federated' and 'skip-networking' was disabled/commented out by default so I had to just enable/uncomment bind-address="127.0.0.1", but it still doesn't work an I doubt it's something with the xampp, but then what it could be?
Stack trace of the error
java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.game.server.model.dao.MySQL.JDBCUtil.<clinit>(Unknown Source)
at com.game.server.launch.LaunchServer.main(Unknown Source)
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.game.server.launch.LaunchServer.main(Unknown Source)
Caused by: java.lang.RuntimeException: Unable to load mysql driver.
at com.game.server.model.dao.MySQL.JDBCUtil.<clinit>(Unknown Source)
... 1 more
.classpath file of the project (REPO_VAR is eclipse variable that points to the /lib/ dir of the project)
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="var" path="REPO_VAR/junit.jar"/>
<classpathentry exported="true" kind="var" path="REPO_VAR/log4j-1.2.17.jar"/>
<classpathentry kind="src" path="test"/>
<classpathentry combineaccessrules="false" kind="src" path="/server-core"/>
<classpathentry kind="var" path="REPO_VAR/mysql-connector-java-8.0.15.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
The project is build via ant so here's the compilation part of build.xml
<target name="build" depends="compile">
<jar basedir="${classes.dir}" destfile="${dist.dir}/${project.name}.jar">
<manifest>
<attribute name="Class-Path" value="log4j-1.2.17.jar server-core.jar" />
<attribute name="Main-Class" value="com.game.server.launch.LaunchServer"/>
</manifest>
</jar>
</target>
The even funny thing is that the project runs well on Eclipse via right clicking the project > Run As > Java Program, so I am totally confused out there.