One-click installation and deployment of Java Desktop applications -- exe4j + Inno Setup takes off with JRE and 8 m

Source: Internet
Author: User

For Java Desktop applications, it is annoying to install and deploy the applications. Check whether the client has installed JRE, JRE version problems, where to download JRE, and how to use JRE to start your Java applications.
Use? 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. If
It is not because of this problem that Java is the most perfect language in my eyes and also my favorite language.
Therefore, I think 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", and cross-platform features are indeed good, but not everyone needs or wants to cross-platform, and sometimes the JVM platform or version problems may cause the embarrassment of "writing once and testing everywhere.
The best way is to use JRE so that users can click it easily. Next, let's solve this problem. If you have any good suggestions or methods, please advise or add more!
For the Windows platform, you can install and double-click the tool, and use the tool exe4j + Inno Setup. Both tools can be found online. If you are not familiar with the tool, you can search for the tool.

When running with JRE, the size of JRE should be the biggest headache. The size of jre6 installed by default is 80 Mb, and the program is only about-kb. It feels unreasonable. Distribution and Network Transmission
The loss process will also be greatly affected! To solve this problem, I have been searching for the "slim version" JRE on the Internet. I have no intention to find an article about mini JRE introduced by beansoft.
After the JRE is downloaded and decompressed for about 14 Mb, I tried it. Some class files are missing from my application. For some XML operation classes, unable to find the category related to the swing desktop application framework,
Finally, I learned from it and reduced a complete JRE from 80 m to 38 m, removing a lot of unnecessary class files. Of course, if you are patient, you can lose weight again, and some class files.
On this basis, we will work with the Inno Setup installation package creation tool, and finally press the entire program from 40 m to 8 M. Let's take a look at the entire operation process, and we will not write any tedious information about JRE slimming, sun's JRE slimming program is also underway. I believe that there will soon be a smaller slim version of JRE, and there is no need to bother myself.

The following is a complete Java program named myloading.


We can see that jre1.6 has been attached. Next, use exe4jto create an exeexecutable file (myloading.exe) and specify our own jre1.6. The following is the startup interface of exe4j. Click Next to create a configuration file.


Next, select the type. We select the first option 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 short file name of your program, the source folder path (such as my: e:/myloading), and the directory of the EXE file to be generated, the EXE directory must be specified under the source folder. Here I will specify it as the root directory of E:/myloading.


Next, you can name the EXE file to be generated, for example, my "myloading". You can also specify an ico icon for it. Others can be created by default ,:


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, you need to add all the jar files you need. You can add them one by one, add the entire folder, or use system environment variables. In order to make your programs run everywhere, so it's still a strong column.
We recommend that you use relative paths instead of environment variables. After adding your class path, return to the previous step and select your "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, we must specify our built-in JRE as the preferred runtime environment. Select:
Search Sequence


By default, the program will go to the Registry, environment variables, and related directories of the system to find JRE. Because we only need the built-in JRE, I removed the default option here, 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 as follows:./jre1.6


The next step is simply to add a startup screen to the program, and then follow the default next step.


The program finally generates the execution file: myloading.exe
Now, we can use our own JRE to start the program, but the entire program is still 40 MB in size.
Now we use Inno Setup to compress and create an installation package.


For the download and installation of Inno Setup, please search online. After installation, start the script Wizard ,:


The process is simple:


Specify the Startup File of your program, that is, the EXE file created with exe4j just now, and include your entire program directory, the next step is basically the next step until the script wizard is complete,


Then execute the script:


Find the default output directory of Inno Setup and you will be able to see the installation package after compilation, for example, myloadinginstaller .exe.
The size has reached 8.86 MB.


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

Related Article

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.