snippetjavaCritical
How can I build JAR files from IntelliJ IDEA properly?
Viewed 0 times
properlyhowfromfilesintellijcanjarbuildidea
Problem
I have a project that contains a single module, and some dependencies.
I'd like to create a JAR file, in a separate directory, that contains the compiled module. In addition, I would like to have the dependencies present beside my module.
No matter how I twist IntelliJ IDEA's "build JAR" file process, the output of my module appears empty (besides a
I'd like to create a JAR file, in a separate directory, that contains the compiled module. In addition, I would like to have the dependencies present beside my module.
No matter how I twist IntelliJ IDEA's "build JAR" file process, the output of my module appears empty (besides a
META-INF file).Solution
Instructions:
File → Project Structure → Project Settings → Artifacts → Click + (plus sign) → Jar → From modules with dependencies...
Select a Main Class (the one with
Select Extract to the target Jar
Click OK
Click Apply/OK
The above sets the "skeleton" to where the JAR file will be saved to. To actually build and save it do the following:
Build → Build Artifact → Build
Try Extracting the .jar file from:
References:
File → Project Structure → Project Settings → Artifacts → Click + (plus sign) → Jar → From modules with dependencies...
Select a Main Class (the one with
main() method) if you need to make the JAR file runnable.Select Extract to the target Jar
Click OK
Click Apply/OK
The above sets the "skeleton" to where the JAR file will be saved to. To actually build and save it do the following:
Build → Build Artifact → Build
Try Extracting the .jar file from:
📦ProjectName
┗ 📂out
┗ 📂artifacts
┗ 📂ProjectName_jar
┗ 📜ProjectName.jarReferences:
- (Aug 2010) Quickly create a JAR artifact for an application (Here's how to build a JAR file with IntelliJ IDEA 10)
- (Mar 2023) Package an application into a JAR
Code Snippets
📦ProjectName
┗ 📂out
┗ 📂artifacts
┗ 📂ProjectName_jar
┗ 📜ProjectName.jarContext
Stack Overflow Q#1082580, score: 840
Revisions (0)
No revisions yet.