Creating a Jar in Eclipse, Including an External Library

I have a Java application that I wrote in eclipse. It works well there.

It works fine from the command line in the directory to which I export it. This directory contains another directory containing the two jar files that I need for the application, and the manifest file has a path class parameter that indicates them.

I want to use eclipse to generate the necessary files to package this application to work on another machine. Is it possible?

If I choose "create jar executable", it creates this huge file; it unpacks and repackages two libraries, which, as I know, are one way to enable their functionality. I would prefer if they stayed like their own banks, but I'm not sure if the eclipse can do this. More annoying is the fact that the jar file executable puts a lot of files from my eclipse project into this jar file. I don’t see the opportunity to choose what is included there, although I see a place to include and exclude "rules" in the project properties. Are they used here? Somewhere else I choose what does and does not get included in the "executable jar"?

If I select "create jar" (ins "create executable jar"), I do not see where it is possible to include these two jar files anywhere. Perhaps there is no place for their inclusion, where they can be used.

If possible, I do not want to use Ant, I do not want to use Maven, I do not want to load another tool. It seems to me that Eclipse already has all this information, and I suspect that it can already do this without having to go and learn another β€œgreat” tool.

+4
source share
3 answers

Eclipse has its own Jar export wizard to create an executable banquet, packed with the necessary library or with the necessary library in a folder away from the jar.

Go to file ---> Export, then select Java - Runnable Jar

export

Then you can choose how to pack the jar and how to handle the libraries:

Jar packing

You can also save ant script for further modification or use ...

+7
source

In fact, you should use Ant or Maven for your task, I do not see another option. Ant is already populated with eclipse, you need to install the JDK, not just the JRE.

Ant is very easy to learn, and you can find billions of examples on the Internet. With Ant, you can do exactly what you want.

Maven is a more modern way of creating and packaging ATMs, as well as much more. Maven is also a good choice for you.

+2
source

I will make vote for Maven. Eclipse has decent maven integration (m2eclipse). Then check this answer to create a jar efficiently using Maven2

Creating an executable jar with Maven 2

0
source

Source: https://habr.com/ru/post/1379367/


All Articles