First of all thank the original blogger can write such a perfect blog, very practical, praise.
Bowen Connection: http://www.cnblogs.com/icewee/articles/2073203.html
The contents are as follows:
Objective:
We all know that Java can package binaries into executable jar files, double-click the jar and double click exe effect is the same, but the feeling is still different. In fact, the Java program packaged into an EXE also requires this executable jar file.
Get ready:
Eclipse, exe4j (online with software and account downloads)
The first step is to package the Java project into an executable jar file, first take a look at my Java project structure, Main.java is the program entry class, which has Main function, config directory is some configuration files, Lib is used in the third party class library
Start packing, simulate (Java project)-right mouse button-export
Pop-up window, select "JAR file" and click "Next"
Uncheck the "config" and "Lib" directories, as well as the project configuration file ". Classpath" and ". Project" generated by Eclipse, and click "Next"
All by default, click "Next"
In the pop-up window, select the MANIFEST.MF file we created ourselves and click Finish
The contents of my MANIFEST.MF file are:
manifest-version:1.0 main-class:bing. Main Class-path:. Lib/ojdbc14.jar lib/poi-2.5.1. Jar Lib/jbcl.jar Lib/jtattoo.jar Lib/liquidlnf.jar Created-by:icewee
The purpose of the executable jar file is achieved by specifying "Main-class". In fact, we finally packaged the project into a exe,class-path can not be specified, in the packaging EXE also to specify the classpath.
The second step, the project packaged into an EXE, here to be clear, not all the files are packaged into an EXE, resource files can not be wrapped in, look down ↓
First, create a folder in any directory, the best name and the same project name, I created a "simulate" folder in F, and then all the resource files and the executable jar files we generated (my Simulate.jar) are copied into this folder. Config directory and Lib directory, if you are afraid to execute the program on the machine does not install the JRE, then you need to copy the JRE directory on your own machine, I installed the JRE5, the last directory structure:
Open the exe4j, skip the Welcome, and click on the second item on the left-hand side of the navigation, because we've packaged the Java project into an executable jar file in advance.
In the pop-up window, select "JAR in EXE mode" and click "Next"
In the new window, take a name for our application, then select the exe-generated directory (my F:\Simulate) and click "Next"
For the exe we want to generate, if you want to generate a custom icon, then select your ico file, if you do not want to run multiple programs on a computer, you can check "Allow only a single ...", click "Next"
Click Green "+" to set the program to run the class Path
First select our own executable jar file (my Simulate.jar), click OK
Our Simulate.jar is added to the class path.
Then click the Main class selection button in general, and in the pop-up window, exe4j will automatically search for the class that contains the main method in all the jars under the current class path and list it, because currently I only select the jar of my own project. And my project only Main.jar contains the main method, so at a glance, directly select it click "OK", the program entry class is set to complete the
After the Main class setting is complete, add all the required third party libraries to class path in turn, with the same method as "Simulate.jar", click "Next"
Enter the Java minimum JRE version number, that is, the JRE below this version will not be able to run the program, then click on "Advanced Options"-"Search sequence", set up our JRE, previously said, if the client machine does not install JRE. That's okay we bundle one in
Click Green "+" to select the bundled JRE location
Select "Directiony" in the pop-up dialog box, then select the JRE folder, note: This JRE directory is that we copy the local JRE directory to the current EXE build directory, my directory is F:\Simulate\jre5, the following diagram program uses a relative directory, click OK , completing the JRE bundle operation
JRE bundle Complete, click "Next"
By default, click "Next"
By default, click "Next"
By default, click "Next"
EXE-generated
OK, finish, click "Exit" to
Let's see how it works.
The total number of our executable jars and the third-party jars is less than 5M, can jre5 directory on more than 50 m, if the target machine has a JRE environment can be deleted, the Lib directory is a third-party jar file, is now packaged into an EXE, so it does not exist reason, then the smallest configuration is left. Simulate.exe "and" config "directory.
Http://www.cnblogs.com/icewee/articles/2073203.html Preface:
We all know that Java can package binaries into executable jar files, double-click the jar and double click exe effect is the same, but the feeling is still different. In fact, the Java program packaged into an EXE also requires this executable jar file.
Get ready:
Eclipse, exe4j (online with software and account downloads)
The first step is to package the Java project into an executable jar file, first take a look at my Java project structure, Main.java is the program entry class, which has Main function, config directory is some configuration files, Lib is used in the third party class library
Start packing, simulate (Java project)-right mouse button-export
Pop-up window, select "JAR file" and click "Next"
Uncheck the "config" and "Lib" directories, as well as the project configuration file ". Classpath" and ". Project" generated by Eclipse, and click "Next"
All by default, click "Next"
In the pop-up window, select the MANIFEST.MF file we created ourselves and click Finish
The contents of my MANIFEST.MF file are:
manifest-version:1.0 main-class:bing. Main Class-path:. Lib/ojdbc14.jar lib/poi-2.5.1. Jar Lib/jbcl.jar Lib/jtattoo.jar Lib/liquidlnf.jar Created-by:icewee
The purpose of the executable jar file is achieved by specifying "Main-class". In fact, we finally packaged the project into a exe,class-path can not be specified, in the packaging EXE also to specify the classpath.
The second step, the project packaged into an EXE, here to be clear, not all the files are packaged into an EXE, resource files can not be wrapped in, look down ↓
First, create a folder in any directory, the best name and the same project name, I created a "simulate" folder in F, and then all the resource files and the executable jar files we generated (my Simulate.jar) are copied into this folder. Config directory and Lib directory, if you are afraid to execute the program on the machine does not install the JRE, then you need to copy the JRE directory on your own machine, I installed the JRE5, the last directory structure:
Open the exe4j, skip the Welcome, and click on the second item on the left-hand side of the navigation, because we've packaged the Java project into an executable jar file in advance.
In the pop-up window, select "JAR in EXE mode" and click "Next"
In the new window, take a name for our application, then select the exe-generated directory (my F:\Simulate) and click "Next"
For the exe we want to generate, if you want to generate a custom icon, then select your ico file, if you do not want to run multiple programs on a computer, you can check "Allow only a single ...", click "Next"
Click Green "+" to set the program to run the class Path
First select our own executable jar file (my Simulate.jar), click OK
Our Simulate.jar is added to the class path.
Then click the Main class selection button in general, and in the pop-up window, exe4j will automatically search for the class that contains the main method in all the jars under the current class path and list it, because currently I only select the jar of my own project. And my project only Main.jar contains the main method, so at a glance, directly select it click "OK", the program entry class is set to complete the
After the Main class setting is complete, add all the required third party libraries to class path in turn, with the same method as "Simulate.jar", click "Next"
Enter the Java minimum JRE version number, that is, the JRE below this version will not be able to run the program, then click on "Advanced Options"-"Search sequence", set up our JRE, previously said, if the client machine does not install JRE. That's okay we bundle one in
Click Green "+" to select the bundled JRE location
Select "Directiony" in the pop-up dialog box, then select the JRE folder, note: This JRE directory is that we copy the local JRE directory to the current EXE build directory, my directory is F:\Simulate\jre5, the following diagram program uses a relative directory, click OK , completing the JRE bundle operation
JRE bundle Complete, click "Next"
By default, click "Next"
By default, click "Next"
By default, click "Next"