[Original] Use install4j to create a Windows installation package for javafx2.x [Part 1]

Source: Internet
Author: User

This blog post is a modification to the previous blog, aiming to streamline the size of the installation package and the space occupied after installation.

 

Problems in the previous article: The same JRE is packaged twice, resulting in the installation package size almost doubled and the space occupied after installation is increased by more than 50 MB.

Cause: After carefully reading the previous article, you can find thatSmarthome0.0.7 _ fat. JarMediumJre7u6 is included, and jre7u6 is statically bound when the installation package is created using install4j.

The final installation directory is as follows:[Note: The image is intercepted later, and the jar in the image should beSmarthome0.0.7 _ fat. Jar], A JRE directory has more than 70 m, but there is also an extracted JRE in the jar package.

 

Purpose: use only one JRE!

Steps:

1. Do not use fatjar, just use eclipse to exportRunnable jar,It must be a runable jar.

 

However, there are three methods to handle the referenced jar package:

(1) extract:ExtractAnd put it in the obtained jar, that is, extract all the class files and package them together with the project files!

(2) package:PackageStored in the jar

(3) Copy:CopyIn the same directory as the jar.

 

Select the third method: Copy!

 

2. Modify the manifest. MF File

In the obtained jar has a folder META-INF, there is a file manifest. MF file, the content is as follows:

Note that the class-path files are all jar files stored in the package-generated folder, which also contains the jar files in JRE.

Therefore, you need to modify this file. Normally, JRE is stored in the JRE folder, while third-party jar packages are stored in the Lib folder. Therefore, create a new Lib folder and put the third-party jar package in the project

The JRE directory does not need to be created, because install4j is used to bind a JRE. It will automatically create a folder in the installation directory and store the bound JRE as long as it knows that there is a JRE directory, the content is the same as the JRE directory installed at ordinary times.

Set manifest. modify the MF file content to: the path of the third-party jar package is similar to LIB/xxxx. jar for the jar package in JRE, the path is similar to JRE/lib/XXXXX. jar, it is recommended to write in one line, because it is easy to make mistakes! After the change, update the jar package.

 

3. Follow the method described in the previous articleSmarthome0.0.8 _ runnablejar_copy.jarCreate an installer. It is still a JRE of static bundle and the JRE created in the previous article.

The difference is that this time we want to add the newly created lib folder, the final installation file directory structure is:

Note: a bug in the previous article. In the previous article, we selected a system compilation variable in the JRE search sequence. In fact, it may not be necessary. It seems that you can just give one. Here is what I see in the install4j help document:

Summary:

1. Static binding of JRE will follow your applicationProgramDeployed together, and it is "green" and does not modify the registry;

2. if the static bound JRE is not shared (this method is recommended), create a JRE folder in the installation directory and decompress the content of the bound JRE to it, this JRE is invisible to other applications;

3. If JRE is statically bound, install4j automatically uses the static JRE as the first item in the JRE search sequence. Therefore, if it is a static binding, you can choose a search sequence.

 

 

 

 

Sometimes you need to ask whether to create a desktop shortcut during installation. This can also be configured in install4j as follows:

On the intaller interface, select register Add/Remove item in screens and actions, and click Add a desktop link in green, as shown in the following figure.

 

The following left-side query box appears. Click OK. Two more items will be displayed, as shown in the right figure.

 

Then configure the target file, that is, the launcher created earlier!

 

4. After the installation is complete, the installation file is about 30 MB, which is about half of the previous version. After the new version is installed, the disk space occupied is about MB, which is reduced by more than 50 MB!

Directory structure after running:

 

 

O (∩) O Haha ~ Enjoy the world of javafx!

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.