0

I'm currently trying to compile my project which would include two external libraries.

json-simple.jar and mysql-connector-java-5.1.42-bin.jar

At the moment I compiling my program and the problem is that i need to include these libraries in the classpath of created compiled project, but i do need only that these libraries would inside .jar project compiled file and i can simply run .jar file and make it work withuot including classpaths or something like that.

Is that possible, don't have idea how.

Ervinas34
  • 133
  • 10
  • 2
    Try the 'Runnable JAR file' wizard of Eclipse. (right click on project > export > java > runnable jar file) – gdros Aug 17 '17 at 07:18
  • You could also try to build it with maven and then you'd end up with a "jar with dependencies". – Pijotrek Aug 17 '17 at 07:20
  • @gdros I tried it, but actually it's not working either. – Ervinas34 Aug 17 '17 at 07:22
  • @Peter777 i don't know how to use maven and something like that, maybe a tutorial about compiling using maven somewhere? – Ervinas34 Aug 17 '17 at 07:22
  • @Ervinas34 Yep, here: https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven – Pijotrek Aug 17 '17 at 07:40

1 Answers1

0

Yes, it is possible.

I'll help you a bit: How to make an executable jar file? Basically unpack the files from the libraries into the folder with your compiled classes (you know how to compile them, right?) then prepare a MANIFEST.MF, put it the folder with all these classes, then create a jar as explained in the answers under the link (jar cfm jarexample.jar jexample.mf *.class). If you have any problems then read the documentation of the commands like jar and javac.

Have fun!

Krzysztof Cichocki
  • 6,294
  • 1
  • 16
  • 32