Java package exe files

Source: Internet
Author: User

First, package the compiled program into a jar file and then execute the exe file so that the code is invisible. However, the exe file cannot run on a computer without jre installed, if you want to install jre again to set the environment variables, it will be indecent. We need to package jre.
There are many plug-ins and methods introduced on the internet for these operations, but some of them are easy to use and some still need to be registered. After comparison, I got a lot of help on the blog "one mile Ice. Sort it out. With these tools, you can also smoothly release your java program!

1. package it into a jar file that can be executed by double-clicking.
Recommended plug-in: fatJar (used by Eclipse)
 
I am using Eclipse. Its own packaging method is not very nice when packaging images and other resources. You can use this plug-in.
Decompress the installation method and copy the net. sf. fjep. fatjar_0.0.24 folder under the plugins folder to the plugins under the eclipse installation directory.
This tool can be used to easily package eclipse projects into jar files. If you want to compress an executable jar file, select the main class.
Your project => Export... => the wizard contains fat jar =>...

2. Convert the jar file into an exe file.
Recommended tool: exe4j
Use exe4j to package java into exe
 
When writing a program, we sometimes have a requirement that our program is an executable file instead of a jar file. In fact, most of the time, all executable jar files can meet the requirements, but if our program needs to be protected, it is not safe to package it into a jar file, because the jar file is a decompressed file, after decompression, you can see everything. Of course, you can also choose to confuse, but after obfuscation, troubleshooting is not that easy, because some class information is confused during obfuscation. How can we ensure code security and easily eliminate errors? Therefore, packaging as exe is a good method. In fact, I do not want you to package it into an exe file today, because the exe file is not cross-platform after all, with the exe format, the original intention of java is lost.
Exe4j can be packaged into various formats of exe. You can package the jar into exe, reference an external jar file, or package it into a windows service program, in addition, you can set the lowest version of jre and the startup screen. Although java6.0 has implemented this, the startup screen generated by exe4j is still not fast.

3. Package the exe file and the jre file into an installation file, which can be run on a computer without the Java virtual machine installed.
Recommended tool: install4j
Install4j Introduction
Http://www.blogjava.net/hadeslee/archive/2007/10/15/152855.html
Install4j is a powerful multi-platform Java installation file generation tool used to generate Java application localization installation and application release. Install4j is easy to use, tightly integrated to the target platform, and flexible JRE management and deployment options.
Create a publishing tree
The graphical user interface of install4j allows you:
* Completely custom publishing tree
In each directory of the publishing tree, you can set the entire directory content or a single file in any directory on the disk. The defined view and result view allow you to have full control over the files that will be released by the installer.
* Handling differences between specific platforms
Install4j provides a convenient "include/exclude" mechanism to adapt to the platform for publishing.
* File permissions defined for Unix, Linux, and Mac OS X
For each element of the publishing tree, you can customize user access permissions when it is installed on a platform similar to Unix.
* Define an excellent uninstall Policy
For each element of the release tree, you can decide whether to delete it during uninstallation.
* Define an overwrite Policy
You can configure different overwrite policies for each element of the release tree. When you need to overwrite files during installation, these overwrite policies will instruct nstall4j to perform corresponding operations.
* Define Installed Components
You can define file and directory groups to form separate installation components, so that you can provide users with the option to install only certain components.
In fact, if a good application is not well deployed, others can only look at it and sigh. Now with install4j, many deployment problems are almost all solved. we can use exe4j to package a java application and then use install4j to publish a java application. Previously, the difficulty in deploying java programs has almost been solved. install4j

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.