1

I have a Project in Eclipse and I want to use a library. When I debug this Project, it works. But when I export it, the JAR is not included, and I get a ClassNotFoundException.

How can I export a Project, and include another (JAR-) File. It isn't a runnable JAR file. I already tried to copy the library in my project, doesn't work.

msrd0
  • 7,816
  • 9
  • 47
  • 82
  • I think Eclipse is able to unpack the JAR-file and pack it into the exported one – msrd0 Oct 11 '14 at 12:05
  • You can also look into this : http://stackoverflow.com/questions/7218506/eclipse-package-multiple-projects-into-one-jar – KiKMak Oct 11 '14 at 12:09
  • Do you use maven? Because with maven there's ways of repackaging your jar for delivery which is actually what you want. – Luis Matos Oct 11 '14 at 15:44
  • By the way, only adding the jar of the library to your project is not enough. You have to add it to the jars on the classpath option when calling java to run your main jar. – Luis Matos Oct 11 '14 at 15:49

2 Answers2

0

You need to use FatJar plugin in Eclipse to pack all your libraries into one jar file, as your dependencies are present in a seperate jar file.

KiKMak
  • 828
  • 7
  • 27
0

Eclipse is able to unpack the JAR and pack it into the generated one. Choose one option at in the export frame (File → Export → Runnable JAR File):

File -> Export -> Runnable JAR File:

msrd0
  • 7,816
  • 9
  • 47
  • 82
  • @DorianHeinrichs Then, why don't you package the other JAR files along with yours? This is the way Eclipse suggests it in your case – msrd0 Oct 11 '14 at 12:31