reprinted from: Http://www.blogjava.net/huliqing/archive/2008/04/18/193907.htmlFor Java desktop applications, it is annoying to install deployment issues, whether the client installed JRE, JRE version issues, where the JRE downloads, how to launch your Java application with the JRE? Do not say that just contact with the computer, is more familiar with the computer, if you have not touched Java, the face of a Java application, how to start it under Windows, it is estimated that will toss half a day. If it weren't for that, Java was the perfect language in my eyes, and my favorite language.
So I think this is the biggest reason why Java desktop apps are annoying to some people, Java's advantage is "write once, run anywhere", cross-platform features are really good, but not everyone needs or want to cross-platform, and sometimes the JVM platform or version problems can also cause "write once, test everywhere" of embarrassment.
The best way to do this is with the JRE, which makes it easy for users to click and run. The following we to solve such problems, there are any good suggestions or methods please other friends to advise or add!
For the Windows platform, let the user one-touch installation, double-click Use, using the tool exe4j + Inno Setup, both tools can be found on the Internet, unfamiliar can be more search, use is not difficult.
With JRE running, the size of the JRE should be the most headache, I installed the default jre6 size of 80M, and the program only 200-300k around, feel very unreasonable, distribution and network transmission process will be greatly affected! In order to solve this problem I have been on the internet search "slimming version" of the JRE, inadvertently found a beansoft teacher introduced a mini-JRE article, the relevant JRE downloaded about 14M after the download, a trial, relative to my application is missing some class files, about the partial XML operation class, and swing desktop application framework related to some of the class also can not find, and finally borrowed a bit, oneself to a complete JRE from 80M thin to 38M, removed a lot of unnecessary class files, of course, if patience is a bit more thin down, and then take out some class files.
On this basis and then with Inno Setup this installation package making tools, and finally the whole program from 40M to 8M, below to see about the entire operation process, about the JRE of the thin body some cumbersome not to write, and Sun's JRE slimming program is also in progress, I believe there will soon be a smaller version of the JRE release , there is no need to bother.
Here is one of my complete Java programs--myloading
You can see that the jre1.6 has been attached, the following first use exe4j to make an EXE executable file (that is, MyLoading.exe), and specify our own jre1.6. The following is the EXE4J Start screen, click Next to start creating the configuration file.
Then choose the type, we choose the first one, so that the program will still have cross-platform features. If you choose the second, you can fully compile the program into an EXE file, you can better protect your program is not anti-compilation.
Next set up your program's short file name, the source folder path (such as my: E:\MyLoading), as well as the EXE file to be generated directory, EXE directory must be specified to the source folder, here I specify it as the root directory of E:\Myloading.
Next, you can give us the generated EXE file name, such as my "myloading", you can also give it an ICO type of icon, the other by default, you can:
In the next step, we need to add the classpath used in the program. Then specify the startup class of the program, other if not necessary, then by default, click on the + sign to add the classpath:
Basically you need to use the jar file to be added, you can add it individually, you can add an entire folder or use system environment variables, in order to make your program can run anywhere, so it is strongly recommended that you use a relative path, and do not use environment variables. After adding your classpath, go back to the previous step and choose your "Main class".
The next step is to select the JRE version we need for our program, and then we choose our own JRE, which is not required, but for better distribution we have our own JRE, so we have to designate our own JRE as the preferred operating environment and choose:
Search sequence
By default, the program will go to the system registry, environment variables and related directories to find the JRE, because we only need to bring the JRE, so here I remove the default option, and then add our own JRE directory path, dot + number start:
It is also recommended to use relative directory paths:
Specifies the directory where the JRE resides,
The final path to my JRE directory is this:. \jre1.6
The following step is simply to add a splash screen to the program, and then press the default next step to do it.
The program is the most lifelong. Execution file: MyLoading.exe
Using it now, we can normally use our own JRE launcher, but the entire program is still 40M in size.
Now we use Inno Setup to compress and make an installation package.
Inno Setup Download installation please go to the online search, after installation, start the Script wizard:
The whole process is simple:
Here you specify the startup file of your program, that is, the exe file created with exe4j, and your entire program directory is included in it, the next basically always press the next step, until the Script Wizard completes,
You can then execute the script:
Then find the default output directory for Inno Setup, and you will see the installation package after compiling the output, such as: Myloading installing the. exe
The size has been pressed to 8.86M.
With this, you can quickly and easily install your Java desktop application.
One click for Java Desktop App installation deployment--exe4j + Inno Setup with JRE, 8M takeoff