A detailed tutorial on packaging Java projects into EXE

Source: Internet
Author: User

A detailed tutorial on packaging Java projects into EXE

Packaging Java projects into EXE is divided into the following two steps:

1. Use eclipse to first hit the Java project into a jar package

2. Use exe4j tool to turn jar package into EXE

Here is an example of a Java project (Exedemo)

Create a new folder in one place, the name of the folder can also be random, here we create a new file on the desktop Exedemo

1. Use eclipse to first hit the Java project into a jar package

(1) Find the Java project to turn into EXE

(2) export the corresponding Java project

(3) Select Java->jar file

(4) Follow the settings below and click Finish

(5) The corresponding jar package (Exedemo.jar file) can be generated

2. Use exe4j tool to turn jar package into EXE

(1) Copy the Jar package lib directory referenced in the Java project to the Exedemo directory

(2) Copy the JRE environment installed on your computer to the Exedemo directory.

(3) in the Exedemo directory, you can create a new image (name can be a random) directory, storage JFrame to refer to the icon

As for the path in the program, refer to the following code:

Mainjframe.seticonimage (Newimageicon (System. GetProperty("User.dir") + "\\image\\logo.jpg"). GetImage ());

(4) Install EXE4J tool (self-surfing, I use EXE4J 5.0)

(5) Open the Exe4j tool and click Next

(6) Select Jar in EXE mode

(7) Input EXE program short name and EXE program output location

(8) Enter the application name, if you want to add the icon for the program ICO, you can select the location of the ICO icon in the Red box at this step.

(9) This step is to choose to generate a 64-bit executable program EXE

(10) This step is to select the jar package to add, package the Java project into the jar package "Exedemo.jar" and the Java project in the external dependent jar package "that is the jar package in the Lib folder" Are added and the main class (Cn.demo.UIMain) is selected according to the actual situation of the Java project. The main class is the entry for your program to run .

If the Java project is UTF-8, in order to prevent the Java project read and write Chinese strings are garbled, you can add the parameter in the Red box location (-dfile.encoding=utf-8)

If the package is garbled, then: Set the code when packaging: exe4j Configurejava invocation Vmparameters

Input:-dfile.encoding=utf-8 to prevent garbled EXE after packaging

(11) Fill in the minimum JRE version requirements

(12) Add and select JRE search sequence, which is the JRE environment search order.

and use the small blue arrow in the lower right corner to put the JRE on the top of the project, let EXE search the JRE preferred to select the Exedemo folder contains the JRE

(13) Select Next

(14) Select Next

(15) The ExeDemo.exe executable can be generated at the end

(16) Double click to run the program.

Article Source: 75116227. The article is very detailed, thank the blogger for sharing

A detailed tutorial on packaging Java projects into EXE

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.