1

Suppose I have multiple classes I want in a .jar. How would I do that in IntelliJ?

Edit: This is just a normal IDEA project. All of the classes compile properly. I want all classes to be in the JAR.

  • Please provide more info. Is your project a "normal" IDEA project, or using a framework such as maven or gradle? Do you already have classes that are compiling properly in your project? Do you want all classes, or just a subset, to be in the JAR? – nanofarad Jan 31 '16 at 01:48
  • Package it? It's not clear what the issue is. – Dave Newton Jan 31 '16 at 03:08

2 Answers2

0

You can check all your classes which will be in *.jar in Intellij ctrl+alt+shift+s (Project settings) -> Artifacts

There you can choose artifacts settings (included classes also)

then, to build package from artifact:

Build -> Build Artifact -> choose created artifact then, in out folder you get your *jar (or another - which you choose in artifact) package

0
  1. Go to File -> Project Structure -> Artifacts

  2. Click on the green plus sign -> JAR -> modules with dependencies

    The module is your entire project.

  3. Specify your main class. Then click OK

  4. Check the "include in project build" box. Then click OK

  5. You can use the terminal of IntelliJ to execute the file

    java -jar "the path to the Jar file"
    
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135