Use EXE4J to package the jar file as an EXE file (bring your own JRE)

Source: Internet
Author: User
Tags relative

Http://blog.csdn.net/shawyeok/article/details/22406137?utm_source=tuicool

We write the program through Java and then package it for the jar package and run it with the following command

Java–jar Example.jar

Here is running on our own machine. But if you want to run the program on other machines, you need some trouble, this article to introduce this method, using the tool for exe4j, through the article at the end of the additional information can be found exe4j download address exe4j Introduction

EXE4J is designed to be used to publish Java programs to a Windows operating system environment, both as a service service, as an interface program, or as a command-line program, and it works well. a complete operation process

The following is a complete operation process to learn exe4j this program, the EXE4J version used here is 4.5.2


1. In the first step can be loaded before the operation of the saved configuration file, through here can see the foreigner to the user experience is indeed very good, because here we do not have so can only step by step


2. Here we have only one jar file, so we choose to use the jar in EXE. If the package contains directories or non-jar files, you cannot use this mode, and you can only choose to use regular mode.


3. Set the program name and the output directory of the generated EXE file, note that the output directory here and the directory where your jar package should be consistent so that he can automatically search the main class


4. Set the type, name, icon, working directory of the Execution program (the default is. The meaning of the current directory of the program), you can also redirect the program log, version information in the advanced options, build the 64bit program, the running level of the program, and so on, it is important to note that if your jar program needs to accept parameters, The allow–console patameter option is to be checked.


5. In this step, we make a good jar file to be added through this green button, and then select the jar package in the main class with the main function of the class. Also here you can set the JVM allow parameters, as well as the program to run the local library and so on, if the program references to other jar packages should also be imported here


6. Set the required JRE version, if there is no maximum version limit to keep it empty.


The point is that if we want to ensure that the released program can run on a machine that does not have the JRE installed, it needs to be posted to the other machines along with the JRE. In the advanced options search sequence to set the EXE program relative to the JRE directory, I am here for. \jre7 and set the search order at the top, stating that the EXE program should be placed in the same directory as jre7. When the program runs, it first looks for java.exe from the bin directory under the Jre7 folder. If you don't find it, you'll find it in turn, looking down, and you'll get an error if you haven't found it.


7. Here you can set the program Start screen, no request can be directly next


8. Set various prompts for program run error


9. Compiling

10. Try to run the generated program, remember that we set the relative path of the JRE in the sixth step. (. \jre7), if you want to run the program, you need to put the EXE with the JRE (folder named Jre7) and EXE in the same directory. If the machine does not set the JRE-related information in the registry and environment variables.


At this point a complete shell process is completed, the first use may appear these unnoticed errors, but by groping + careful can quickly master this handy tool.

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.