JavaRush /Java Blog /Random EN /How to create an executable jar in Intellij IDEA / how to...
Roman_kh
Level 33
Харьков

How to create an executable jar in Intellij IDEA / how to create jar in IDEA

Published in the Random EN group

Creating an executable jar in Intellij IDEA

As it turned out, it is not so easy to find information about this on the Internet. There are many references to how this is done in Eclipse, but not much more is said about Intellij IDEA. That's why I created this post. How to create an executable jar in Intellij IDEA / how to create jar in IDEA - 1IntelliJ IDEA allows you to quickly create an executable JAR file of your program containing modules with all dependencies. In order to create a JAR, you need to do only 3 steps:
  1. Click the ' + ' button in the Project Structure dialog box and select the appropriate item (Figure 1):
    How to create an executable jar in Intellij IDEA / how to create jar in IDEA - 2
    Figure 1 – Project Structure -> Artifacts -> Jar -> From modules with dependencies

  2. Next, IntelliJ IDEA shows a dialog that allows you to configure a new artifact (Figure 2):
    Here you need to select the main class of your project and click OK
    How to create an executable jar in Intellij IDEA / how to create jar in IDEA - 3

    Figure 2 – Dialogue for creating a new JAR artifact

  3. After clicking OK, you can create a Jar file using the Build -> Build Artifact
    menu item . By default, all libraries will be extracted into the target Jar. The executable file itself will be generated in the out -> artifacts directory of your project (Figure 3):
    How to create an executable jar in Intellij IDEA / how to create jar in IDEA - 4

    Figure 3 – Location of the generated JAR file

    That's it, now the executable file can be launched.

See also my other articles:
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION