Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - Extract/package the required libraries into the same Runnable JAR

When exporting a project as a Runnable JAR file using Eclipse, there are three choices:

1. Extract required libraries into generated JAR
2. Package required libraries into generated JAR
3. Copy required libraries into a sub-folder next to the generated JAR

However, it seems that only one of the three choices could be chosen from the Runnable JAR File Export window. I wonder if there are some ways that could mix up these methods, e.g., extracting some of the files while packaging the rest?

Note: I need this since one of my JAR file contains a ton of references to other files so 1 cannot be an option, and I am afraid that 2 might be causing some problems for me.

Thanks!

like image 889
zw324 Avatar asked Jul 07 '11 18:07

zw324


People also ask

How do I extract a runnable jar?

To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.

How do I export a referenced library in Eclipse?

Goto File -> Export -> Java -> Jar. Select it to pack all of the referenced libraries.

What is the difference between runnable jar and jar?

FYI: In simple terms, the difference between a JAR file and a Runnable JAR is that while a JAR file is a Java application which requires a command line to run, a runnable JAR file can be directly executed by double clicking it.


1 Answers

What you can do is choose "1. Extract required libraries into generated JAR" and save the build as an Ant script. Then after it finishes, edit the ant script and remove the libraries that you do not want to be extracted.

like image 157
Garrett Hall Avatar answered Oct 21 '22 18:10

Garrett Hall