Patrick O'Hara
Patrick O'Hara

Reputation: 571

Can I create an Eclipse Project that produces multiple executable Jars?

I have a project with a library JAR and a set of applications. Right now the applications (all 5 of them) are in a single project. These tools each have one or two classes, they run from the command line with one exception. Even the GUI tool has only about 8 classes. I am struggling with how best to structure this in Eclipse.

I have seen that I can use maven-shade to create multiple executable JARs from one project. I would need to convert the project to Maven, but I assume that is not a big problem.

I can create a separate project for each tool. This seems like overkill to have several projects with one or two classes in each.

Additionally, both of these solutions will leave me with either a bare class file or a JAR plus the dependent library JAR. Not ideal for deployment.

Before I pick one of these, I thought I would ask here if there is a different approach that I am missing for packaging these tools.

Upvotes: 2

Views: 331

Answers (2)

Dante
Dante

Reputation: 772

Yes, but You could/need to create using Maven, and for each build building jar you need to set the main Class. Checkout the documentation of Maven. I think You could to the same with Gradle, but not sure.

https://maven.apache.org/plugins/maven-jar-plugin/examples/attached-jar.html

Upvotes: 0

Yohannes Gebremariam
Yohannes Gebremariam

Reputation: 2265

In eclipse, Export --> Archive file, You can select/deselect what classes you want to export into your Jar File

Upvotes: 1

Related Questions