One-click installation and double-click running -- Java installation program Creation

Source: Internet
Author: User

Question: one-click installation double-click to run -- Java installation program production
Author: Jason Du
Time:
Original article: http://www.blogjava.net/javapro/archive/2009/03/24/JavaAppSetup.html

For Java Desktop applications, installation and deployment problems are cumbersome, such as whether the client has installed jre, jre version, where to download jre, and how to use jre to start Java applications. Don't say that people who are new to computers are familiar with computers. If they are not familiar with Java, how to start a Java application in Windows may take a long time. Therefore, this is the biggest reason Java Desktop applications are hated by some people. The advantage of Java is that it is "one-time writing and runs everywhere". cross-platform features are indeed good, however, not everyone needs to perform cross-platform operations, and sometimes JVM platforms or versions may cause "one-time writing and testing everywhere" embarrassment. For Java applications on a fixed platform, the best way is to use JRE so that users can run it easily by clicking it. Next we will solve this problem.

For the windows platform, the main method is: first streamline the JRE, then use the tool exe4j to solve the problem of double-click running, and finally package it into an installer using Inno Setup, our Java applications are the same as common windows applications.

Download this article

This document is in PDF format.
Http://www.uushare.com/user/javapro/file/1418624
Http://www.rayfile.com/files/7840998c-1824-11de-942b-0014221b798a/

Sample programs in this tutorial
Http://www.uushare.com/user/javapro/file/1418316
Http://www.rayfile.com/files/3ee1f95c-1826-11de-bcfb-0019d11a795f/

Exe4j 4.2 registration Edition
Http://www.uushare.com/user/javapro/file/1418327
Http://www.rayfile.com/files/c56bebba-1826-11de-9b55-0019d11a795f/

Inno Setup Chinese enhanced version + ISTool Chinese version + decompilation set + ISFD Interface Design Chinese Version
Http://www.uushare.com/user/javapro/file/1418305
Http://www.rayfile.com/files/95c91dd9-1826-11de-89b1-0019d11a795f/


I. Simplified JRE

JRE6 is installed at a size of about 90 MB by default, while the general program is only a few MB or even several hundred kb and runs with JRE. It feels unreasonable and the distribution and network transmission processes will be greatly affected. For more information about JRE streamlining, see the following articles:

Jre of Java program release
Http://www.blogjava.net/gdws/archive/2006/12/25/89898.html

How to create the smallest RCP program compressed package (including JRE)
Http://www.eclipseworld.org/bbs/read-cec-tid-5777.html

Let the Java program carry a streamlined jre (with tools)
Http://glemir.xplore.cn/archives/200

JRE ultimate streamlining exploration manual [1]-streamlining a Swing real-time strategic game
Http://cping1982.blog.51cto.com/601635/129630

Java application-a small tool to streamline the size of JRE
Http://blog.csdn.net/cping1982/archive/2008/09/02/2865198.aspx

JVM rt. jar streamlined tool graphical shell 0.1
Http://www.blogjava.net/beansoft/archive/2008/12/19/247321.html

Run RCP/Swing mini JRE 6 (3.75 MB)
Http://www.blogjava.net/beansoft/archive/2008/01/18/176353.html

Run the SWT Lite version JRE 1.4.2 _ 04, which is only 1.3 MB after compression.
Http://www.blogjava.net/beansoft/archive/2007/03/07/102381.html

In general, JRE streamlining is a complicated task. If you are not clear about some features, do not delete them easily. Otherwise, some unknown errors may occur. The pack200 compression tool will produce errors when compressing some repackaged rt. jar files. If you use the pack200 compression tool, pay attention to the output information on the console.

Ii. Use exe4j to generate the exe Executable File

The following is a complete Java sample program named TestProcessBar. We can see that the sample program has already attached a jre. Next, use exe4jto create an exeexecutable file (testprocessbar.exe in the figure) and specify our own jre.


 
The following is the startup interface of exe4j. Click Next to start creating the configuration file.
 

Next, select the type of the exe file to be created. Here we select the first one. In this way, we create a starter for the program that can be double-clicked to ensure that the program still has cross-platform features. If you select the second one, you can fully compile the program into an exe file, which can better protect your program from decompilation.

Next, set the program's short file name and the source folder path (you can use the relative path of the exe4j project file. Here, my exe4j file is saved in the launcher directory, so the Source Path used is [...], directory), and the directory where the exe file to be generated is stored. The relative path of the exe directory is the source folder. Here I specify it as the current source folder.

Next, you can give us a name for the generated EXE file, for example, my example testprocessbar.exe ". You can also specify an ico icon for it. Others can be selected by default ,:


 
Here we can also add some information to the exe file to be generated.

In this step, we need to add the class paths used in the program. Then specify the startup class of the program. If other programs are not necessary, click the default class path and add the class path by +:


 
Basically, we need to add all the jar files we need. You can add them one by one, or add the entire folder or use system environment variables. In order to make the program run everywhere, we recommend that you use relative paths for strong columns, and do not use environment variables. After adding the Class path, return to the previous step and select "Main Class.

Next, select the jre version required by our program, and then select our own jre. This step is not required, but for better distribution program, we bring our own jre, therefore, it is necessary to specify our built-in jre as the preferred runtime environment and select Search sequence.


 
By default, the program will go to the system registry, environment variables, and related directories to find jre, because we only need the built-in jre, so here I have removed the default option (if necessary, place the default option after the built-in jre option without deleting it ), then add the directory path where our own jre is located, starting with "+:


 
The relative directory path is recommended here:

Specifies the directory where the jre is located,

Finally, my jre directory path is like this:. \ jre


 
In the following step, you can set it if you are interested.


 
The program finally generates the execution file: TestProcessBar.exe
Now, we can use our own jre to start the program, but the entire program is still nearly MB.
Now, you can publish a compressed package. However, in order to compress more data and make programs easier to use, we use Inno Setup to compress and create an installation package.

3. Use Inno Setup to create a package and installation program for the program

Start the script wizard after installation ,:
 

Specify the program Startup File, that is, the exe file created with exe4j. Then, you can include the entire program directory (this is because the program has some exe4j and inno setup engineering files, so you have some choice ), the next step is basically the next step. Set the output directory of the installation program until the script wizard is complete.

Then execute the script:

Find the output directory of Inno Setup and you will see the installation package after compilation, for example, setup.exe.
The size has reached 6.38 MB.
 

With this, you can quickly and easily install your Java Desktop Application.
 

 

Iv. Summary
In general, we aim to make it easier to write programs. Through the above learning, we can now create a simple and easy-to-use program installation package that can be double-clicked to run without the need for another jre installation. You can learn more about jre simplification, preparation, packaging, and installation of exe starters. The tools in this tutorial are just a reference, and there are many tools with similar functions to be studied. Finally, I hope you can develop your own simple and bright one-click Java program.
Link: http://www.blogjava.net/javapro/archive/2009/03/24/JavaAppSetup.html

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.