Home > Java > javaTutorial > How Do I Create a JAR File with Dependencies in IntelliJ IDEA?

How Do I Create a JAR File with Dependencies in IntelliJ IDEA?

Barbara Streisand
Release: 2024-12-17 19:20:12
Original
947 people have browsed it

How Do I Create a JAR File with Dependencies in IntelliJ IDEA?

Creating JARs with IntelliJ IDEA: A Comprehensive Guide

Q: How do I create a JAR file containing compiled code and dependencies?

A: Building JARs in IntelliJ IDEA:

To build a JAR with IntelliJ IDEA, follow these instructions:

  1. Open File > Project Structure.
  2. Navigate to Project Settings > Artifacts.
  3. Click the (plus sign) > JAR > From modules with dependencies....
  4. Select a Main Class (containing the main() method) if desired.
  5. Check Extract to the target Jar.
  6. Click OK.
  7. Click Apply or OK.

This sets up the JAR configuration. To build and save the JAR:

  1. Go to Build > Build Artifact.
  2. Select the JAR artifact you created.
  3. Click Build.

The JAR will be saved in the following directory:

?ProjectName
|
┗ ?out
|
┗ ?artifacts
|
┗ ?ProjectName_jar
|
┗ ?ProjectName.jar
Copy after login

References:

  • (Aug 2010) [Quickly Create JAR Artifact](http://blogs.jetbrains.com/idea/2010/08/quickly-create-jar-artifact/)
  • (Mar 2023) [Packaging into JAR](https://www.jetbrains.com/help/idea/compiling-applications.html#package_into_jar)

The above is the detailed content of How Do I Create a JAR File with Dependencies in IntelliJ IDEA?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template