One, foreword

Said a few days ago a friend looking for me, there is a data interface development can show the small projects page, that can be run locally, don’t need on the Internet, can ask me to do, would have declined, but to hear that, can give some hard, and came up with Li bai big poet said: the life your bosom friend, why gold and money. Friends? Isn’t that what we do for each other? This function can be done, I come to me, you can do, and not money doesn’t matter, main is to want to do something for a friend, cough cough cough, get to the point, my friend, he is not a developer, so the project done, let him to install the JDK, tomcat, is not realistic, and grope for a moment later, Then use Exe4J to package the JAR into an EXE file.

Second, development environment

Development tool: IntelliJ IDEA Jdk version: 1.8 Project framework: Spring Boot 2.2.1.RELEASE Exe4J tool: 5.1 Project type: Java Web project

Iii. Project packaging

3.1 Project directory structure

This is the normal jar project under the normal Spring Boot, we create the normal operation on the line, the following is the directory structure after I will finish the project, we can refer to it.

3.2 Packaging generates jars

Find the Maven button in the right toolbar of the IDEA tool

Second, generate project executable JAR

Operation steps:

  1. clean:Clean up theTo do some cleanup before the actual build, remove all the files generated from the last build. Running this command will delete thetargetFile, but will not delete jar files already generated by the local Maven repository.
  2. install:Install to a local warehouse, installs the package into a local repository for other projects to rely on. Will be generated under the project pathClass files and JAR packagesAnd will also be localMaven repositoriesGenerate jar files that can be used by other projects
  3. package:Project package, package the project files into the specified format,Examples include Jar, War, etc. This command will be in your project path nextThe target directoryAnd ownThe compile commandThe function will compile at the same timeThe target directoryGenerate the project underThe jar/war file, in which thejarThat’s what we need.

Other commands(Since this article only uses the above three, here are a few to go over) :

validateVerify that the project is correct and the required information is complete.

compileCompile the source code, compile the class files, compile the commands, compile only the selected target, regardless of whether it has been compiled before, and generate a target directory in your project path containing a classes folder full of generated class files and bytecode files.

test: Unit tests

verify: verify, check whether the package is valid and conforms to the standard.

site: site, which generates site documentation for the project

deploy: Copy to the remote repository

Get the executable JAR

Once it’s generated, we can go to theThe target directoryLet’s see what we needThe jar file



4. Copy the JAR file and place it in a unified folder

Iv. Tool preparation

It is important to note that the JAR files generated with IDEA will include both the dependent JAR files and the configuration file in the project JAR, so we do not need to add the dependent JAR or configuration file separately.

Jar files to be generated

Second, the conversion tool: EXE4J link: pan.baidu.com/s/1EDxFr56q… Extraction code: AHNT

Jre file in JDK



Iv. Complete document display

All you need is the JAR of our project and the JRE file in JDK. If you need to customize the icon, you can put it in an ICO file

Important: all files are put together, we need to package to others, jRE1.8.0_101 and project JAR also need to send to others !!!!!

5. Use Exe4J for conversion

After downloading and installing, the interface is shown in the picture. The first step is registration.

The Name and CompanyB: Just fill it out

Registration code: A-xvK258563F-1P4LV7mg7sav



Click Next when you’re done

5.1 Selecting JAR in EXE

Package the JAR into an EXE program, and next

5.2 Enter the name and save path of the packaged EXE program

5.3 Entering the file name and icon information of the EXE

5.4 Selecting an OPERATING System (OS) if the OS is 64-bit, ensure that the OS selection box is selected



5.5 Adding the JAR Path to run

Note: Since IDEA automatically exports the required JARS and configuration files when exporting the SpringBoot project JAR, there is no need to add other dependency packages and configuration files





Pay attention to: What we need to add in Spring Boot isorg.springframework.boot.loader.JarLauncherNot the one we run every timeWebApplication

5.6 Enter the JDK version that you can run. 1.8 is used here

5.7 Packaging jre





5.8 Proceed to the Next step until complete

5.9 Generating the EXE Program File

We’ll find an extra EXE file in our package, so we’ll hit Run. If there is an error message, there is an error log file in this file. You can view the log content

Note: files should be kept together and not separated!!

5.10 Effect display, this can be used without Java environment, has been verified by my friend

Close the app

So once we open this, what if we need to close this application? Don’t worry, it’s all ready for you, we just need to write a very simple script.

Textweb. exe is the name of my own application, I can change it to my own

6.1 Creating a TXT File for closing programs

6.2 Copying commands to TXT Files

@taskkill /f /IM textWeb.exe

6.3 Change the file suffix to.bat

6.4 Re-accessing our application fails

7 complete

All we need to do is compress the files in this folder and send them to the people who need them. This works even if the other party doesn’t have a Java environment.

If you think there is any improvement or question in the operation, you are welcome to leave a message below, the blogger will reply to you as soon as he sees it. I am a small farmer, I feed myself with salt, I go with you and me on the way to study, everyone come on!