Convert the Jar file to the exe installation file, and install the jar file.
After checking on the network and using the exe4jtool for real-time conversion, the basic steps of the software are as follows:
1. you need to know whether the target file is 32-bit or 64-bit. If the generated file is 32-bit, you need to use a 32-bit jre. If the generated file is 64-bit, A 64-bit jre is required.
Figure 1
Select 32bit or 64bit in the circle. Because I want to create 32bit, the default value is used.
2. JRE configuration (if not configured, various JAVA_HOME errors will be reported ):
The hosts file is also in this directory.
Figure 2
Click search Sequence of the sixth JRE in Figure 1. The page is displayed:
Figure 3
Delete these three items, and then re-select the jre directory, and specify the directory as the jre folder in the "HJ helper 1.1" folder.
Figure 4
In this example, the .exe executable file can be executed without the error shown in. You can also send the "HJ assistant 1.1" folder to your computer without jre installed.
3.The. EXE file behind the conversion cannot display image resources.
My project is a Swing project, which requires some icons. Because it is the .exe execution file, the class loader is used to read image resources, rather than the URL address.
ImageIcon icon = new ImageIcon(ImageIO.read(getClass().getClassLoader(). getResource("frame.png")));
Another important point is that the folder for storing images must be a system resource folder. Otherwise, the image cannot be obtained and the folder is set as a resource folder.
4. even though a runtime. EXE file has been generated, the jre folder should also be put together when it is used by others, so the folder size seems to have reached more than 100 MB, but your original file is actually very small, therefore, I use the Inno Setup packaging tool to package the folder into an installation file, which reduces the occupied capacity. The Inno Setup tool is easy to use and can be downloaded to the Chinese version on the network. Here is a note during the packaging process:
: When adding a folder, you need to add the top-level directory of the jre folder. In this project, it is the "HJ helper 1.1" folder. Otherwise, the jre file cannot be found during running.
The installation file of the. exe can be produced quickly, with a size of over 30 mb, much smaller than the original folder.