How does IDEA create a jar package of single or multiple class files?

1 Introduction

Sometimes we encounter a jar package that contains multiple class files in a project. Here is how IDEA creates a jar package (non-module).

2. Problem solving

2.1. Step one: Select Project Structure in the upper right corner

Method one:
![](https://img-blog.csdnimg.cn/c93a89b6e47849d9a86ccd0555f9f6cf.png
Method two:
Insert image description here

2.2. The second step

Insert image description here

2.3. Create a new empty jar. The default name is unnamed. You can change the name of the jar package according to your own needs.

Insert image description here

2.4. Click New Directory in the upper left corner to create a new directory, and then create a new directory.

Insert image description here

2.5. The newly created directory structure must be consistent with the directory structure of the project.

Insert image description here

2.6. Select “+”–>File

Insert image description here

2.7. Note that the selected file is a compiled .class file. Select one or more as needed. After adding the file, select "Apply"->"OK"

Insert image description here

2.8. Select Build–>Build Artifacts… in the upper left corner

Insert image description here

2.9. Select the newly created jar, Build/Rebuild is available.

Insert image description here

2.10. Find the jar you just typed in the file.

Insert image description here

2.11 If you can't find it, you can create a new jar. There is an Output directory, which is the file directory where the jar is located.

Insert image description here

Guess you like

Origin blog.csdn.net/qq_45278500/article/details/121815112
Recommended