I'm doing simple java application that interacts with mySQL database. It should run on the Ubuntu Server. I'm developing it in the Intellij IDEA, and it works great there.
However, when I generate jar file and launch it in the Ubuntu command line (both server and my home PC running ubuntu), nothing works.
I simply type java -jar %my_jar_filename%
and get the error
"Couldn't load main class ... Class.forName("com.mysql.jdbc.Driver")"
I know that since java 5(i'm not sure here which version, I use 8) it's not necessary to write it, but if I don't write it I get
"No suitable driver found"
I googled this problem and the only solution I found was to make sure the driver actually exist on the PC and add that Class.forName("");
It doesn't help me. Driver exists, because in the IDE program works. I think the trouble is with java options.
I tried to add mysql connector via java -cp
,
but it gave me the same error and even tried to compile the program in terminal from source via javac, but also the same issue.
On my PC mysql connector is in the folder usr/share/java/
The server where application should finally work has the same settings What am I doing wrong?
**SOLVED:**Thanks everybody The solution was quite simple. This answer helped https://stackoverflow.com/a/45303637/9184305