Java. after the class, if you just use Java commands to execute it, you may not think it is too enjoyable. It is interesting 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.
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 manifest. 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 is simple and 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
Someone asked me that this is not always the case. The reason is: if the name of your program is corresponding to the path of the compressed package, it is better to say that the program you write
Package com;
Public class myjava {
Public static void main (......){....}}
COM/myjava. classes in the jar package. If you do so, the package is successful!
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.
Note: You need to print it to the console (console) and select the second one.
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. Select the JRE version, enter the maximum and minimum JRE versions, and continue.
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 text location 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 and check the effect. What is the starting effect set by myself? How does it feel?