-1

again me.

I dont know what the hell isnt working right, but everytime im exporting my Teamspeak Bot wrote in Java, it seems like he dont export the mysql-connector.jar. Everytime im trying to start my jar, he always tells me that he cant find the MySQL-Driver.

Heres my Code:

As you can see, the jar file is in the buildpath. When i try running it through Eclipse, everything works fine. Only when im exporting he throws me the Exception.

Hope someone of you can help me.

ndslr

miselking
  • 3,043
  • 4
  • 28
  • 39
ndslr
  • 47
  • 2
  • 8
  • @Satya if im running it on centos, which lib folder? java lib folder, centos lib/lib64 folder? tried all of them, nothing worked – ndslr Jul 20 '15 at 17:49
  • How exactly are you exporting your jar? – Kevin Workman Jul 20 '15 at 17:54
  • show us deploy options; to what @Satya meant is if you are using some sort of container - you need to add `lib` folder that contains all of you jar files on your class path – Алексей Jul 20 '15 at 17:56
  • @KevinWorkman http://i.imgur.com/dS6blDM.png Im exporting it as a normal jar with these options. – ndslr Jul 20 '15 at 18:00
  • @Алексей So you mean i should create a new Folder named "lib" in my project and put the jar there? – ndslr Jul 20 '15 at 18:00
  • it depends... if you use tomcat or jetty for example then by going into deploy assembly you should indicate what jar you would want to be in the `lib` folder; if on the other hand it is a stand alone app then you should provide a `--classpath` option, if however you can not specify `--classpath` option then you need to add jars into your jar file. Once you can indicate how do you run your app we can help you better – Алексей Jul 20 '15 at 18:27

1 Answers1

0

The way you're exporting your jar, your library jar isn't automatically added to the output jar. You would have to specify the classpath when you run it:

java -cp "C:\Users\Andy\Desktop\mysql-connector.jar;YourOutputJar.jar" TS3BotMySQL

Instead, you have to add the mysql-connector.jar to your output jar. To do this, instead of going to export > jar, go to export > runnable jar, and then select "Extract required libraries into generated JAR" or "Package required libraries into generated JAR" at the prompt.

See these related questions for more information:

How to create a jar with external libraries included in Eclipse?

Eclipse Java; export jar, include referenced libraries, without fatjar

Generating a Jar in Eclipse including external library

How export Java jar from Eclipse with dependencies on other jars?

Community
  • 1
  • 1
Kevin Workman
  • 41,537
  • 9
  • 68
  • 107