Java projects are packaged as EXE files with exe4j
Preface: We all know that Java is platform agnostic. Can be packaged into jar files, to any operating system with the JRE environment of the computer can agree! But we pack into EXE file is equivalent to abandon this big advantage, just do have to pack into EXE time!
Here's how to package a Java program into an EXE executable file.
Preparation tools:
Eclipse,exe4j(exe4j: Http://www.pc6.com/softview/SoftView_68764.html#download If the installation encounters problems, See: http://blog.csdn.net/xlgen157387/article/details/38404063)
The first step is to Java The project is packaged into a running Jar file, first look at my Java Project structure. This is very easy, just take a look at my project (temporarily written)
(1) Right-click on the Project (CHP02), select export--to find Java---Runnable JAR file then next
(2) In Lanch Configuration Select Start Main program Main in export destination select the folder and name you want to save. and finish.
(Pop-Up dialog box, click OK!)
)
(3)
Generate Hello.jar File
The second step is to package the project as EXE
(1) It is important to understand that not all documents are packaged into one EXE , resource files are not included, look down ↓
First, create a folder in the Free folder. The best name and project name are the same
(Suppose you are afraid that the machine running the program is not installed JRE . Then you need to copy the JRE folderon your machine as well, and the final folder structure:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvegxnzw4xntczodc=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
(2) Open exe4j, skip the Welcome, and click on the left side to navigate the second item directly. Since we've packaged the Java project in advance to run the jar file,
In the pop-up form. Select "JAR in EXE mode" and click"Next"
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvegxnzw4xntczodc=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
(3) in the new form, take a name for our app, then select EXE Generate a folder (my Desktop ), click the Next "
(4) Name the exe we want to generate . Suppose you want to generate your own definition icon. Then choose your ico file, assuming you don't want to execute multiple programs on a single computer. You can check the "Allow only ... ". Click "Next"
Click the green "+" to set the program execution Class Path
Click on "+" to select Archive to select our own runnable jar file (my hello. jar), click OK
Our Hello.jar is added to Class Path .
(5) then click Generalin theMain ClassSelect the button, in the pop-up form,exe4jwill voluntarily search the currentClass Pathunder the allJarincluded inMainmethod of the class, and listed, because currently I have only selected my project'sJar, and my project has onlyMain.jarincludes aMainmethod. So at a glance, select it directly and click on "OK", the program entry class is set to finish
After the Main Class is set. Add all the required third-party libraries to class Path in turn . Method join "Hello.jar", click "Next"
(6) Enter the Java minimum JRE version number, that is, the Jre below this version number cannot execute the program, then click "Advanced Options"-"Search sequence", set up our JRE, Said before. What if the Jre is not installed on the client ? That's okay we bundle one in
Click the Black section of the right sidebar
Click on the Green "+" to select the bundled JRE location
Select "directiony" in the pop-up dialog, then select the JRE folder , note: This JRE folder is the The JRE folder is copied to the current exe generated folder , the program uses a relative folder, click OK. bundled operation of JRE finished
JRE Bundle Complete, click "Next"
By default, click "Next"
By default, click "Next"
By default, click "Next"
EXE in Build
Click on the " Exit "You can
My program becomes an effect such as the following:
View the properties of Hello.exe
Our running jars and third-party jars are less than 5Min total, and Jre8 folders are more than M. Assuming the JRE environment on the target machine is able to delete it, it is now packaged in an EXE, so it has no reason to exist. Then the minimal configuration leaves the "Hello.exe" folder!
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Java projects are packaged as EXE files with exe4j