Create non-executable JAR from selected classes in IntelliJ

intellij-idea, jar

Solution

I don't know if you need this answer anymore, but I had the same issue today and I figured out how to solve it. Please, follow these steps:

- File -> Project Structure (Ctrl + Alt + Shift + S);

- Go to the "Artifacts" Menu -> click on the "+" button -> JAR -> From modules with dependencies...

- Select the module you want to generate the Jar file;

- Don't select any main class;

- On the JAR files from libraries menu, select "extract to the target JAR" option -> Click Ok;

- Name your jar file -> select the output directory -> Click "Apply" and "Ok";

- After these steps, go to: Build -> Build Artifacts...

- A flying menu will appear with the artifact that you have previously created;

- Click Build and it's done.

Hope that that helps you and everyone that have this issue. I wasted all day trying generate the jar file on Eclipse with FatJar and I couldn't generate it.

Problem

In Eclipse, there is an option Export -> JAR File. Then we select desirable classes which want to export to output jar. How can we do that in IntelliJ?

Original source