This article was adapted from: Lebyte

SpringBoot is packaged into an EXE program

For more Java related knowledge, you can follow the public account “LeByte” to send: 999

preface

Recently, I have done a spring boot project with the combination of the front and back end, but it requires an EXE file, which is provided for the installation and use of small white people who do not understand the computer. I went to study for a long time and stepped on a lot of pits. Writing this article, I want to see this article, according to my steps, can step on less pits.

To prepare

Preparations:

  1. A JAR package, no bug can start jar package

  2. Exe4j, a tool to convert a JAR into an EXE

  3. Inno Setup, a tool that combines dependencies and exe into an installer, baidu Cloud link as above

start

In my case, I have the JAR package on my desktop

Open the installed Exe4J

Go to the next step and select JAVA to EXE

Then click Next, enter a name and output path

Continue to click Next and select boot mode

There is an option below to make the packaged application compatible with 32 – and 64-bit systems

Check it when you come in

Then proceed to the next step, and the following screen appears, starting to select the JAR package and configuration

Add -dfile. encoding= UTF-8 to the VM parameter configuration

Click Next to configure JRE

Click the drop-down box to enter the following interface

The purpose of this is to eventually package the local JRE directory with the EXE, and let the EXE file find the packaged JRE by itself, without installing the JDK

Next, select the Client VM

Then proceed to the next step, and finally the following screen appears

This time you will find the desktop more than a demo. Exe file, this time do not worry about the point open, next is the JRE and exe file to hit a package merge, to achieve in the absence of JDK computer environment can also run.

Open inno Setup, top left corner file-new

Go to the next step and fill in the configuration, application name, version, etc., at will

And then I’m going to hit Next, which is the default, and I’m going to go to next

Then select the generated EXE file

And then the next step, go to this screen keep the default, go to the next step

Still the next step, never mind

Moving on to the next step, here is selecting a language

Then it is time to select the output path and fill in the name of the installer

And then the Next step, go straight to Next, and finish

The last step of the configuration, the script file, will pop up here and ask you if you want to compile right now, select no, write the script first and then compile it yourself.

Then the final step is to write the local JRE into the script

Source: “own local JRE path *”; DestDir: “{app}{#MyJreName}”; Flags: ignoreversion recursesubdirs createallsubdirs

It will prompt you to save the current script, call it whatever you want, and use it the next time

Then wait for the green scroll bar to end

When the green scroll bar ends, the desktop will have a setup.exe file

At the same time will pop out an installation, because the program to help you automatically start the generated installation program, installation can be, remember to check the installation of shortcut

This is the last program, double-click to run you can see the result, the setup.exe file to others to install, you can see your program

Thank you for your recognition and support, xiaobian will continue to forward “LeByte” quality articles