Create a new folder in any directory, name the Java program and copy the JRE that the Java program is using into the folder you just created.
Second, export the jar package from MyEclipse.
1. Right-click on the project to export:
2. Export type Select runnable JAR file and click Next:
3. Select the entry for the program, generally choose the class where the main function is located:
4. Click Browse to select the folder you just created:
5. File name generally fill in the names of Java programs, you can also use other names, fill out and click Save, finally click Finish, complete the export of the jar package:
6. Open the CMD window to test if the jar package will run successfully, note the Java command followed by the-jar parameter:
Third, use EXE4J to convert the exported jar package into an EXE executable program.
7. Open exe4j and click Next to proceed to the next step:
8. Select the jar to convert to EXE mode:
9. Fill in the application name, directly fill in the Java project name, and then select the EXE file directory, choose the folder just created:
10. Select the generated EXE program type, here I select the console program, and select the same time the same machine can only run one of the program:
11. Fill in the name of the EXE that will be generated, can be arbitrarily named:
12. Under this option, select 32bit or 64bit:
13. If the generated program executes under a 32-bit operating system, do not tick this, check this to ensure that the program refers to the JRE is also 64-bit, or the program does not work:
14. Always next until this interface appears, click the Green plus sign to add the jar package just exported:
15. Add the jar package just exported:
16. Set the main function entry:
17. Because I used JDK1.7 and I put the JRE in the newly created folder, I filled in 1.7 here:
18. Click Advance option to select Search sequence:
19. Here is the order in which the program is chosen to find the JRE, we delete all three items:
20. Click the green plus sign after deleting it:
21. Select Directory:
22. Select the JRE in the folder you just created:
23. Click OK, then next:
24. Next, until the interface appears, click Exit and Exit Exe4j:
25. The newly created folder now has 1 JRE folders, a jar file, and an EXE program:
26. Double-click Exe4jDemo.exe, pop up a window, output Hello world!, but the program output after the end so will immediately close the window, this is how many times I have tried to succeed down, at this point, with the exe4j to the Java program into EXE executable program is completed:
Convert a Java program to an EXE executable using exe4j