IDEA 8.X/9.0: Build Jars function to include all classes from reference project Libs


i facing current with problem from the jar builder.
Full Version IDEA 8.X and 9.X

I build a Jar file with following options.
1. The 3rd party libs can include to the target jar.

By option 1. the commons-lang-2.4.jar will include in myapp.jar.
But can not found by the default java-class-loader. (java -jar myapp.jar)
Explanation on this site.

So i have switch back to eclipse for this function.

Eclipse has menu "File>Export>Runnable JAR file" do copy the content of any
LIB to the myapp.jar.

So the problem not exist on eclipse side.
Is there any way to get the same result on IDEA.
Without write a custom class-loader?


1 comment
Comment actions Permalink

There are three ways to solve this:

  1. You can extract external jars and repackage them with your application (that is build a jar that includes your application and all external libraries)
  2. You can repackage the jar with the jarjar Ant task
  3. You can deliver external jars with your application and specify the classpath in the manifest of your application.

Hope this helps.


Please sign in to leave a comment.