Java. after the class, if you just use Java commands to execute the file, it is not too fun to find a way to generate a file that can be executed by double-clicking with the mouse like an EXE file. Here I use a free small software called exe4j. It feels good.
First, download an exe4j file. My version is 2.2, license: L-g782dn2d-1f1yqxx1rv1sqd.
Next, you need to select the. Class file you are about to release. The following is a jar file. Here I use the name D: myjavatest. for example, write a file manifest to determine main_class. mf, Here mainfest. MF and myjava are in the same directory (both are in D :), and then run the following command:
Jar cvfm test. Jar manifest. MF myjava
Manifest. MF didn't know how to write it at the beginning. It was so crazy... Haha. The Code is as follows:
Manifest-version: 1.0
Main-class: myjava. Test
Created-by: hanic
You only need to write the main-class pair. In this way, a test. jar file is generated. Here I will not elaborate on the specific functions of jar. But to ensure the success, we can use the following command to execute the generated test. jar:
Java-jar test. Jar
How can we proceed smoothly? If yes, we can start creating executable files.
The Application of exe4j is quite simple. Similar to the dummies, it's okay to enter and select individual parameters all the way to next. A little understanding of e can be applied freely. Don't say you don't understand e! No way. Let's simply describe the process:
1. Open exe4j. You can enter the license to open the config file you have previously operated on.
2. Click the next key, select the "jar in EXE" Mod button, and click Next.
3. Enter the short name and file output path, and click Next.
4. Here you can select the type of the executable file you want to generate, the name of the generated executable file, and the icon of the executable file. Here we select GUI application, you can set a name based on your needs. You can select an icon you like in your icon library and click Next.
5. Enter the name of main class and click green + to select the. jar file. If there are no special requirements, we can continue.
6. Next, select the version, and enter your maximum and minimum versions before continuing.
7. Set the title of your file execution to improve its aesthetic effect. Select your favorite image, write the text you want to write, and adjust the position of the text as needed, continue.
8. The following is a language version selection interface.
9. The following is a short wait, and the result is that an executable file written in Java is generated in this way.
10. Double-click it to see the effect. The starting effect is set on your own.
Generation steps
A) Use eclipse to compress the required main class into a jar package that can be run independently. Pay attention to adding the manifest attribute and mainclass.
B) Create an exe4j Project
C) select "jar in EXE" Mode
D) configuration in configure application:
I. Short Name: Write it casually.
Ii. ourput driecloud: select the output path.
E) configuration in configure executable:
I. executable type: There are three options: graphics, console. or service. Let's start from a simple single point. Here we choose Console
Ii. executable name: enter the name of the target output source. For example, test.exe
Iii. icon file: EXE icon file, but it must be a. ICO file (many images of this type can be liked on the Internet)
F) configuration in configure Java invocation:
I. classpath: select the generated jar package and the class library required to run the JAR file.
Ii. Main-class: select the main class we need to run.
Iii. Arguments (optional): enter a parameter. We do not need it for the moment.
G) configuration in configure JRE:
I). Minimum Version: Write the minimum JVM version required to run the program, such as 1.4.
H) Keep running next. All the steps are default until finish: OK. After compilation is successful, there will be a brand new exe program in your output directory.