How to import a Java package into an exe file
Use exe4j to package jar to generate exe
Eclipse is used for packaging and exe4j is used to generate exe files. This is required. You can download version 4.0 from the Internet.
First, select a project you want to Export packages to in eclipse, then click file, select Export in the pop-up options, and then select Runable JAR
File option,
Next, select the project you want to export the package to, and export the package to the desired place,
Click NEXT and select Details in the pop-up prompt box;
In the pop-up chassis, select the class that contains the main function in your project.
No problem!
The detailed steps are as follows:
1. welcome-open exe4j
If you have saved the project packaging configuration file, click> open. If there is no point> next.
2. Project
Type-select the packaging method
Because we are talking about packaging jar to generate exe, select "jar
In
Exe "mode. In this way, you can package a java application into an exe file, but you cannot package additional files except jar. Then> next
3.
Application info-configure the generated Application information
Set the name of your application and the output folder of the executable file to be generated. Then> next.
4. Executable
Info-configure the parameters of the executable file
Type is determined based on the type of your program. In this example, it is a GUI program; next, the file name, the executable file icon, whether to allow only one application to run at the same time, whether to throw an exception when the main thread encounters an error, and change the working directory (relative to the executable file ). Click> advanced
Options> version info
5. version
Info-set version information
6. java
Invocation-configure the runtime environment
Configure class first
Path, delete all the original configurations in this item, and click "+" to find the jar file you generated,
Then click the Browse button in the general section above. exe4j will automatically find the entry to your application-main
Class.
At the bottom of the advanced
Select native in options
Libraries settings, this function is to add external jar package files used by your program, I have never used this, because I like to concentrate on everything, therefore, all the external packages used in the program are fully integrated into jdk/jre. This way, you only need to pass the program to the client when installing the program, no need to install other things, they will like it very much. After all, users are not engaged in programming.
7. jre-configure jre
Configure your jre version type here, and then see> advanced
Option> search sequence
Here, you can configure the location of the jre/jdk required to run the program. If you only run the program on the local machine after packaging, you can directly specify the jre/jdk directory on your local machine, if the packaged program is to run on another client and the machine does not have jdk installed, another method is required. From the customer's point of view, the software should be installed as little as possible to bring tedious installation matters to the customer, it is best to just click the mouse to automatically install. Therefore, we need to save the trouble of installing jdk. To solve this problem, we can place the installed jdk copy in the root directory of the final product, and then add this jdk copy to the running environment of the program.
Search
Registty can scan installed jdk/jre. We select directory to specify a jdk directory for the program, just locate the jdk root directory, as shown in.
Then> next
It should be noted that only one jre is required for the program developed with eclipse, and jdk is not needed. Therefore, I package jre into the exe runtime environment, in this case, the one under java version allows the use of jre.
The option for beta is selected.
8. preferred
Vm-select Virtual Machine
This is selected based on the actual situation. In this example, It is client.
Then> next
9. splash
Screen-preload form
You can set your preload form interface here, but it seems that you only recognize gif images, status
Line and version line can be in position text lines
Adjust the display position on the visually preview page. Next, select the language interface and select the language based on your needs. Then> next
10. compile
Executable-compile and generate executable files
Automatically jump:
Here, you can click the generated executable file, or save the configuration scheme for future use.