Turn jar files into EXE installation files

Source: Internet
Author: User

These days my girlfriend asked me to help her do a Windows platform to export Excel file tools, considering the time problem, choose the most proficient language Java to achieve. But eclipse's packaged files are suffixed with a jar, and to run this file, the JRE must be installed, which is unnecessary for non-developers, so I'm going to convert the. jar file to an. exe file.

Check on the network, using the EXE4J tool to achieve the conversion, the basic steps of software use I will not say, next to create a 32-bit. EXE target program, for example, tell some of the problems that may occur:

1. You need to know whether the target file is 32-bit or 64-bit, if you generate 32-bit, you will use a 32-bit JRE, if you generate 64-bit, you will use a 64-bit JRE.

Figure 1

Select 32bit or 64bit at the circle position. Because I want to create a 32bit, I use the default.

2.JRE configuration (not well configured to report various Java_home errors):

I first create a folder called "HJ Small assistant", then put my executable program Limitvic1.1.jar and the JRE folder in, and later generated. exe files are also placed in this directory.

Figure 2

Click on the sixth JRE search Sequence in Figure one, and the interface will appear:

Might

Delete all three items and then re-select the JRE directory to specify the JRE folder in the "HJ Small Helper 1.1" folder.

Figure Four

The. exe executable can be executed in such a way that it does not report the error as shown, and the "HJ Small Helper 1.1" folder is available to a small partner who does not have a JRE installed on the computer.

3. The converted. exe file cannot display the picture resource.

My project is a swing project, which requires some icons. Because the. exe executes the file, the class loader is required to read the picture resource, and the URL address cannot be used directly.

New ImageIcon (Imageio.read (GetClass (). getClassLoader ().                    GetResource ("frame.png"));

It is also important that the folder where the picture is placed must be a System resource folder, otherwise the picture cannot be obtained and the folder is set as a resource folder.

4. Now that you have generated a executable. exe file, but it is necessary to use the JRE folder for others to put in, the folder size seems to reach more than 100 trillion, but your original file is actually very small, so I use Inno Setup packaging tools, Packaging a folder as an installation file can reduce the amount of capacity that is consumed. The Inno Setup tool is also very easy to use and can be downloaded to the Chinese version on the Web. Here is a note on the packaging process of the problem:

: When adding a folder, to add the top level directory of the JRE folder, in this project is "HJ Small Assistant 1.1" This folder, or run when the JRE file can not be found.

Depending on the Script wizard steps, you can quickly produce an. exe installation file with a size of more than 30 megabytes, which is much smaller than the original folder.

Turn jar files into EXE installation files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.