Reputation: 2849
I am creating an executable jar file for my program in java. The program uses jtds.1.2.jar and javacsv-2.0.jar.
Is it possible to include the external jars when I create my executable jar file??
Please help. Thank you.
Upvotes: 1
Views: 176
Reputation: 29595
It's possible to create a folder structure like this
main directory: your_app.jar subdirectory: other jar files
Then add the dependencies to your jarfile's manifest and "zip" the whole thing together, to move it to the computer where you want it to be. Netbeans, for example, supports this kind of deployment.
For a more general / "foolproof" solution, you will have to create a setup program.
Upvotes: 0
Reputation: 33534
Try this, this is the way to create a jar or runnable jar in eclipse, all your external libraries in the project will be included
File -> Export-> Java ->Runnbale JAR file
Launch configuration : your Class containing the public static void main(String[] args)
Export destination : Target place
Library Handling:
Package required libraries into generated JAR
FINISH
Upvotes: 1
Reputation: 9608
Yes it is possible.
You may use eclipse export jar function doing this
Upvotes: 1
Reputation: 10606
Sure it's possible! Just add the classes of the Jars to your Jar!
You can either do this by hand (unsuggested), or any build tools like Ant ( target) and Maven (search for shading plugin) can do that for you.
If you don't want to bother creating any scripts, just use the IDE to do it for you (newer Eclipse versions have a checkbox for including libraries automatically, for older ones just install a plugin that does the job for you automatically, like the FatJar plugin).
Upvotes: 0