How to Import Modules and Build JAR Files in IntelliJ IDEA
This step‑by‑step guide shows how to create an IntelliJ IDEA project, import a Java module into it, associate the module with the project, and then package the application into a JAR file using the IDE’s Project Structure and Artifacts settings.
IDEA Import Project Module
1. Create an empty project
To import a Module you first need a project because modules exist under a project in IDEA.
Here we create an empty project for demonstration; if you already have a project the process is the same.
2. Import Module
Locate the project directory on your local disk:
3. Associate the Module with the current project
These three steps import the required Module into the project; a project can import multiple Modules.
You can also open a module directly:
IDEA Package Java Program into JAR
1. Select the Module to package
Click File → Project Structure → Artifacts
Explanation: Main Class – click the small icon to choose the class containing the main method (e.g., App).
Explanation: Set META-INF/MANIFEST.MF . Click the arrow icon to configure; defaults are fine.
Explanation: If an error appears, a META-INF folder already exists. Delete the existing folder via Explorer (right‑click the module → Open in → Explorer).
If no error occurs, you will see a "puzzlegame:jar" prompt. Click OK.
2. Build the JAR artifact
Click, and the following dialog appears:
3. Locate the built JAR
Click File → Project Structure → Artifacts. The generated JAR can be found at the path highlighted in the screenshot.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Captain
Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
