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. IntelliJ 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:- Click the ' + ' button in the Project Structure dialog box and select the appropriate item (Figure 1):
Figure 1 – Project Structure -> Artifacts -> Jar -> From modules with dependencies -
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 OKFigure 2 – Dialogue for creating a new JAR artifact -
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):Figure 3 – Location of the generated JAR file
That's it, now the executable file can be launched.
GO TO FULL VERSION