Package idea into jar and run

Preface

If you want to package the code of your idea, search for tutorials online.

It’s already 2023, and the packaged jars of idea, to put it bluntly, don’t work.

Finally, I solved this problem after reading the packaging tutorial on the jetbrains official website.

Create your first Java application | IntelliJ IDEA Documentation (jetbrains.com)

illustrate

Idea uses a new version of UI

Demo

1. New key a project---only

 2 including hello world

 And hello world written by Main under org.example.

3 Open the project structure

 4 Come to the artifact

 Then click '+'

Select empty or next item, it doesn't matter

My current options are

5 Select the main category

 If you don’t want to modify anything else, you don’t need to modify it, just leave it as default.

Click OK twice to come to the generated MF file.

 6 Packing

right mouse click

 Select the package file at the bottom. After generating the jar file, run it directly

The result will be like this,

 7 Edit the running environment--the most important step

Came to this page

 Fill in the working directory

 Move the mouse wheel down and come here.

Click +

 

 Select Compile Artifacts.

 Check the directory.

Click OK to run.

8 results

Summarize 

It bothered me all night. Although it is very simple, unfortunately none of the online tutorials I saw worked. Alas, I accidentally clicked on the tutorial and solved this problem. It was comfortable.

Although the problem is the same, it still requires different methods to solve it. Only I have experienced it myself.

(0.0)(0.0)(0.0)(0.0)(0.0)(0.0)

         (0.0)(0.0)(0.0)(0.0)

                (0.0)(0.0)(0.0)

                         (0.0)(0.0)

                                (0.0)

Guess you like

Origin blog.csdn.net/qq_63401240/article/details/131466756