Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a Jar in Eclipse including external library

I have a java application I've written in eclipse. It works fine there.

It works fine run from a command line in the directory where I export it to. In that directory is another directory containing two jar files that I need for the application, and the manifest file has a Class-path option specifying them.

I want a way to use eclipse to generate the necessary file(s) to package this application to run on another machine. Is that possible?

If I choose "create executable jar file", it creates this huge file; it does unpack and repack the two libraries, which I know is one way to get their functionality included. I would actually prefer it if they were left as their own jars somehow, but I am not certain eclipse can do that. More annoying is the fact that the executable jar file option puts lots of files from my eclipse project into that jar file. I don't see an option to choose what gets included there, though I do see a place to enter inclusion and exclusion "rules' in the project properties. Do those apply here? Is there somewhere else I go to select what does and does not get included in the "executable jar"?

If I choose "create jar" (ins of "create executable jar"), I don't see where there's an option to include these two jar files anywhere. Perhaps there is no place to include them where they could be used.

If possible, I do not want to use Ant, I do not want to use Maven, I do not want to download another tool. It seems to me that Eclipse already has all this information and I suspect it can already do this without having to go and learn yet another "nifty" tool.

like image 912
arcy Avatar asked Jan 19 '23 09:01

arcy


1 Answers

Eclipse has its own Jar export wizard for generate a runnable jar packed with required library or with the required library in a folder aside the jar.

Going in File ---> Export then choose Java - Runnable Jar

export

You can then choose how pack the jar and how handling libraries :

Jar packing

You can also save the ant script for later modification or use ...

like image 177
aleroot Avatar answered Jan 28 '23 16:01

aleroot