Java Desktop programs packaged into exe--can be installed or run on a computer that is not installed in Java __java

Source: Internet
Author: User

For Java desktop applications, the more annoying is the installation of deployment issues, whether the client installed JRE, JRE version of the problem, where the JRE to download, how to use the JRE to start your Java application. Do not say that people who have just contacted the computer, is more familiar with the computer, if not touched Java, face a Java application, how to launch it under Windows, it is estimated that will toss half a day. If not for this problem, Java in my eyes is the most perfect language, but also my favorite language.

So I think this is the biggest reason why Java desktop apps are annoying to some people, Java has the advantage of "write, Run Anywhere", cross-platform features are really good, but not everyone needs or want to cross the platform, and sometimes JVM platform or version problems will cause "write, test Everywhere" of embarrassment.
The best way to do this is to take the JRE with you and make it easy for users to click. Below we solve such a problem, what good suggestions or methods to invite other friends to advise or add.

For Windows platform, let user one-click installation, double-click the use of tools exe4j + Inno Setup, these two tools can be found on the Internet, unfamiliar can be more search, use it is not difficult.

With JRE running, JRE size should be the most annoying, I installed the default jre6 size of 80M, and the program only about 200-300k, feel very unreasonable, distribution and network transmission process will be greatly affected. To solve this problem I've been searching the web for the "slim version" of the JRE, accidentally found the Beansoft teacher introduced an article on the mini JRE, the relevant JRE download after decompression about 14M, a trial, relative to my application is missing a number of class files, about part of the XML Operation class, and swing desktop application framework related to some of the classes are also not found, and finally borrowed a bit, their own a complete JRE from 80M to 38M, remove a lot of unnecessary class files, of course, if patience can also be thin down, and then remove some of the class files.

On this basis to cooperate with Inno Setup this installation package production tool, finally the entire program from 40M to 8M, the following to see about the entire operation process, on the JRE of the thin body some cumbersome will not write, and Sun's JRE slimming program is also in progress, I believe that soon there will be a smaller version of the JRE to launch , there is no need to bother.

Here is a complete Java program for me--myloading

You can see that the jre1.6 has been shipped, the following first use exe4j to make an EXE executable file (that is, the MyLoading.exe above), and specify the jre1.6 we bring. The following is the EXE4J launch interface, click Next to start creating the configuration file.

Then select the type, and we choose the first one, which guarantees that the program still has cross-platform features. If you choose a second, you can completely compile the program into an EXE file, you can better protect your program is not decompile.

Next set up your program's short name, source folder path (such as my: E:\MyLoading), as well as the EXE file to generate the directory, EXE storage directory must be specified in the source folder, where I designate it as the E:\Myloading root directory.

Next, you can give us the resulting EXE file a name, such as my "myloading", you can also give it to specify an ICO icon, others by default, as shown:

In this next step, we need to add the classpath used in the program. Then specify the program's startup class, other if not necessary, then by default, click the + number to add the classpath:

Basically, you need to add the jar file, you can add it individually, you can add the entire folder or use the system environment variables, in order to enable your program to run anywhere, so still strong column recommended you use relative path, and do not use environment variables. Add your classpath and go back to the previous step to choose your "Main class".

The next step is to select the JRE version that our program needs, and then to select our own JRE, which is not necessary, but we have the JRE for better distribution, so we have to designate our own JRE as the preferred operating environment, as shown in the figure:
Search sequence

By default, the program will go to the system registry, environment variables and related directories to find JRE, because we only need to bring the JRE, so here I remove the default option, and then add the directory path where our own JRE resides, point + number begins:

It is also recommended that you use a relative directory path:

Specify the directory in which the JRE resides, as shown in the figure:

Finally my JRE directory path is like this:. \jre1.6

The following step is simply to add a splash screen to the program, and then press the default next step next.

The program is the most lifetime of this executable file: MyLoading.exe

Using it now, we can start the program with our own JRE, but the entire program still has a size of 40M.

Now we use Inno Setup to compress and make an installation package.

Inno Setup download, go to the web search, after the installation of the Start Script Wizard, as shown in the figure:

The whole process is simple:

Here specify your program's startup file, that is, just use exe4j to create the EXE file, and your entire program directory is included in it, and then basically continue to press the next step on it, until the Script Wizard completes,

You can then execute the script:

Then find the default output directory for Inno Setup, and you can see the installation package after the output is compiled, as shown in the following figure: Myloading installation. exe

The size has been pressed to 8.86M.

Use this to quickly and easily install your Java desktop applications.

Original: http://binary.duapp.com/2012/11/585.html

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.