Java program to package JRE and make installation package

Source: Internet
Author: User

Share an article: Java programs package JRE and make installation packages

Chuan Zhi & Dark Horse Consulting Mr. Zheng




Java program to package JRE and make installation package
Java Desktop program can only be run in eclipse after the operation is not possible, but also need to copy the program to other computers to run, so you need to make the other computer can run files, of course, on the computer installed with the JDK only need to export the program as a jar file can be run, But instead of installing the JDK on the computer where the Java program is being developed, there is no such environment on other people's computers, so it is also necessary to package the Java-ready environment in the program so that it can be run without the user installing the JDK.
The process of making an executable file
first, after the program is written, export the jar file.
1. Right-click the project file in Eclipse and select Export





2. Select Export as runnable jar file, then next




3. Select the main portal window of the application, save the path of the jar, export the file, select the first second can, they all contain the library files required by the program, the first benefit of the export is to prevent the program from being recompiled, the second can retain the original file structure, and then finish



4. Locate the exported JAR file,




second, run the file with the Java command
1. Open a Command Prompt window and locate the JAR directory




2. Run the jar file using the Java–jar command



3. Enter to see the program run up



4. But the program does not have pictures, look closely at the size of the jar package can guess no resource files, with WinRAR view jar internal structure found without these resources




third, the resource files required by the program are copied to the same directory of the Jar1. Locate the file resource that is required in project except SRC



2. Copy these file resources to the same directory as the JAR package




3. Run the jar file again to find that it contains files such as pictures





d. Convert the jar file to an EXE file that can be run directly by double-clicking
1. Converting a jar file to an EXE file there is a good software called Jar2exe, official:
HTTP://WWW.REGEXLAB.COM/ZH/JAR2EXE/FREE.HTM[/U]
We download the green version

2. Download and then directly unzip, run the J2ewiz.exe file inside










3. See the Startup window without registering directly next



4. Locate the path to the jar, select the version of the minimum run JAR file, and click Next





5. Select Windows Window program, next








6. Select the application's Entry window, set the animation at the time of opening (can not animate), next



7. Ignore all options and go directly to the next step




8. You do not need to add a dependent jar package, the next step



9. Set the output path file name, you can also set the EXE file icon, click Next





10. If you have an environment variable configured on your computer, and you do not need to copy the program to another computer, you can click Done directly.








11. If you need to replicate to other computers that do not have a JRE environment, then you must first keep the above window and copy the JRE to the same directory as the jar file just now.





The path to the JRE is the path where you install the JDK, and mine is C:\Program files\java\jre1.6.0_07.
12. Then select the parameter Configuration button for the window, and configure the path of the JRE to the relative path of the jar package.
Select the JRE Settings tab, select Profile specify ', select relative path, then edit




Locate the Jvm.dll in the JRE and then make sure that the application is ready.





At this point in the folder will be more than a config file, this file can be EXE file reference to the same directory of the JRE environment,







13. After the conversion is complete the jar can be deleted, double-click EXE to run, to see the effect:

14. In order to verify that this program can run on a computer that does not have a JDK installed, we test that opening the Win7 flagship version of Xpmode,xpmode is an XP virtual machine for Win7, which is a complete XP system that copies files to XP,





15. Double-click Kejian.exe to see the effect:



16. Although the program has been completed, but we can not give users a folder, and then let the user copy, copy and then double-click EXE to run the program, so we will also make the installation package.
Five, the Production program installation package
1. The software required to make the installation package is named Inno Setup, the software is completely free and can be downloaded from the 360 security defender's software butler,




When installed, the compiler chooses the Unicode version, and of course, ANSI is also available, but the supported encoding is not as high as Unicode.
2. Install and open the program later choose to use the wizard to create the script:






3. Direct Next





4. Set the program name, program version, company name, company URL information after the next









5. Direct Next





6. Locate the exe file and the folder where the EXE is located, next

7. Set the name of the folder displayed on the user's computer after the installation of the program, and some Start menu options, etc., you can choose your own, then next




8. These settings are optional and go directly to the next






9. Select Simplified Chinese, next






10. Set the output path, installation package name, install password installation file icon and other information, you can default, next



11. This step can not be, direct next



12. Click Finish

By the completion of this script, the script can be executed to get the installer.
13. Select Yes




14. Can not save, voluntary, click on the self-compilation




15. After completion if you choose to save the compilation script then in the compilation script the same directory will have an output folder, if not save the compilation script, then the user's my document will have an output folder, which is the resulting installation file:






16. Install the package here to make it, you can test it, the method is very simple, no longer write.

The picture in the article may not display properly because of the anti-theft chain or the non-existent relationship above is your friend through the QQ mailbox reading space to share to you.

This article is from:

Chuan Zhi & Dark Horse Consulting Mr. Zheng

    • Java program to package JRE and make installation package
    • 12 most frequently asked PHP face questions
    • Java Basic Enterprise Face question
Subscribe to Reading Space

Java program to package JRE and make installation package

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.