Expand the JAR option and click From module with dependencies. In the Project Structure window, click Artifacts in the left pane, then click the plus symbol. Click Project Structure from the file menu.Ģ. Configure the project settings to define the artifacts of this project. Once you’ve created a project and a Run Configuration, which can be used to execute the project, let’s set up your program to export a JAR from the IntelliJ workspace.ġ. You’ll also need to create a main class with some simple functionality. Dependencies are external programs packaged as a JAR with some functionalities implemented already and can easily be reused in your program. Before starting up, you’ll need to create a project and add the necessary dependencies to it. In this method, you’ll export a JAR using the IntelliJ build option. Export a JAR Using the Build Artifact Method This program also uses Picocli and Apache Commons Cli as external dependencies, which will support validating and parsing the command line parameters. To understand the tutorial better, you’ll use a simple example program that accepts user profile information as a command line argument. In this tutorial, I’ll explain the two different methods for setting up your project architecture to export a JAR from IntelliJ: IntelliJ provides a couple different ways to export a JAR from your workspace. Simply put, you can start an executable JAR directly just by double-clicking on it. On the other hand, an executable JAR can be executed directly without any external program. You can only add it as a dependency to other programs and access the classes and functions in your program. Normal JARs have no entry point, meaning you cannot directly execute this type of JAR. There are two types of JARs: normal and executable. Packaging your application into a JAR makes it easier to distribute your program, and it also means functionalities in your program are reusable-for example, other programs can use your functionalities just by adding your JAR file as a dependency.
A JAR ( Java archive) file is a platform-independent package of your application in a single archive file.