EXE4J packages IDEA (Maven) projects and comes with a JRE runtime environment

EXE4J packages IDEA (Maven) projects and comes with a JRE runtime environment


Preface

I recently encountered a special need at work: I need to monitor the CPU and memory usage of the Chrome browser on a Windows computer and make judgments based on the thresholds I set. If the threshold is exceeded, I will request interfaces such as Enterprise WeChat or Feishu to go to the corresponding group. Push relevant news.

Here I choose to use java to develop relevant code (mainly because I don’t know anything else)

After developing the code, I suddenly realized that it needs to be run on a Windows computer that does not have a development environment on site, so it needs to be packaged into an exe file and needs to be accompanied by a running environment.

I found a lot of information on the Internet about packaging java code into exe through exe4j software, but most of them have some problems. After a long time of exploration, I finally got it, so I will make a record here, and hope it can help. Students with relevant needs. I will try to record all the steps in detail, so you should be able to follow them directly.


1. IDEA packaging (note that this is a Maven project)

Directly to the picture

1、File → Project Structure

![Insert image description here](https://img-blog.csdnimg.cn/6ef84bbe8c9f43b591349e3d5edc19b9.png

2. Select project

Insert image description here

3. Select the main category

Insert image description here

4. Click OK

Insert image description here

5、Build Project

Insert image description here

6. Click Build again, select Build Artifacts, select the project and click Build.

Insert image description here

7. Get the jar package from here and copy it to the desktop

Insert image description here

At this point we have completed the packaging. The next step is to turn the jar package into an exe executable file.

2. Use exe4j software to package the jar into an executable file and attach the running environment jre

Download exe4j tool

There will be no demonstration on downloading and installing here, there are many on the Internet. Try to crack it, otherwise you will be reminded to use the free exe4j version after packaging the exe file and executing it.

Start packing

1. Start exe4j and click next

Insert image description here

2. Select the project type and click next

Insert image description here

3. Fill in your project name and select the location where you want to output it after packaging.

Insert image description here

4. Fill in the application name and select your icon

Insert image description here

5. Select 64-bit

Insert image description here

Insert image description here

6. Next add your jar here

Insert image description here

7 Select the main category

Insert image description here

8. Select the jdk version (the highest version does not need to be filled in) and check the box to allow the use of jre with version number.

Insert image description here

9. Select your environment (that is, the jre file in jdk)
. Note: The file location is more important. The demo shown in the figure is the path to output the exe.

Insert image description here

Insert image description here

Remove these three and add jre

Insert image description here
Insert image description here

next

Insert image description here

10. Select the preferred JVM to launch the program

Insert image description here

11. Then continue to the next step here and click to start your application

Insert image description here

It should be able to start successfully here, and then you can put the entire folder (the entire folder with exe and jre) on a computer without a jdk environment to test whether it can start. If it can start and run, it will be successful.


Guess you like

Origin blog.csdn.net/weixin_55549435/article/details/129123675