Search code examples
javaeclipsejarrunnable

How to attach libraries to JAR file?


It works fine when compiling project, but after exporting it to a runnable jar and launching, it can't find external files and throws an error. What should I do?


Solution

  • You could attempt building a fat jar that includes all the jars. It contains a custom class loader to load the jars referenced externally by your project.

    Try using http://fjep.sourceforge.net/ plugin to build a fat jar.

    You can export a java project containing jars using the File -> Export -> Other -> One Jar Exporter.

    enter image description here

    The jar thus exported works fine.