Home  >  Article  >  Java  >  How to generate exe executable file in Java

How to generate exe executable file in Java

WBOY
WBOYforward
2023-05-18 21:59:146060browse

1. Software preparation

1. Download the tool EXE4J that converts jar packages into EXE.

2. After the download is complete, follow the steps below to install EXE4J.

How to generate exe executable file in Java

How to generate exe executable file in Java

How to generate exe executable file in Java

How to generate exe executable file in Java

How to generate exe executable file in Java

#2. Produce jar files

Before converting the written Java program into an EXE program, you need to export the Java program into a jar package first, and then generate the desired EXE through EXE4J program. Here, the tool I use is eclipse. The specific steps are as follows:

1. Open a Java project that contains the main method and has been debugged and runnable. Right-click and select export, and then select JAR file under the Java option. options.

How to generate exe executable file in Java

Select the Java project to be exported and specify the jar package export path. Click finish to see the generated jar package in the corresponding path.

How to generate exe executable file in Java

3. Convert the jar file into an EXE file

1. Open exe4j Wizard.exe and register the license on the home page. , otherwise the generated exe file will prompt: "this executable was created with an evaluation exe4j" when running. You can use the following registration number when registering:

A-XVK258563F-1p4lv7mg7sav

A-XVK209982F-1y0i3h5ywx2h2

A-XVK267351F-dpurrhnyarva

A-XVK204432F-1kkoilo1jy2h4r

A-XVK246130F-1l7msieqiwqnq

A-XVK249554F-pllh451kcke50

A-XVK238729F-25yn13iea25i

A- XVK222711F-134h6ta8yxbm0

A-XVK275016F-15wjjcbn4tpj

A-XVK275016F-15wjjcbn4tpj

2. Click next and select "JAR in EXE" mode.

How to generate exe executable file in Java

3. Click next and fill in the generated application name and output directory.

How to generate exe executable file in Java

Click Next, make a selection based on your application category, and enter a name for the executable file. The remaining options can be set according to your own needs.

How to generate exe executable file in Java

The generated EXE runs first in the 32-bit JDK environment by default. If the operating system of the target computer is 64-bit, you should check the following options to be safe:

How to generate exe executable file in Java

## 5. Click next to add the jar that needs to generate EXE Package and set its mainclass.

How to generate exe executable file in Java

How to generate exe executable file in Java

When using the Java API, set the minimum and maximum version limits of the runtime jre to Adapt to different application scenarios.

How to generate exe executable file in Java

Then, set the JDK dependencies required when generating EXE files. If Java has been correctly configured into the system environment variables, this step can generally be skipped.

How to generate exe executable file in Java

When you see the following interface, converting the jar file to the corresponding exe file has been completed. At this time, you can open the corresponding exe file to see if it is running normally.

How to generate exe executable file in Java4. Possible problems

1. When executing the EXE file, java.lang.NoClassDefFoundError
# is prompted

##You used a third-party jar package in your program, but failed to associate it when generating the EXE file. The referenced third-party libraries need to be included in the ConfigureJava call. How to generate exe executable file in Java

How to generate exe executable file in Java

2. When executing the EXE file, java.lang.UnsatisfiedLinkError is prompted

How to generate exe executable file in Java

This is Because in the jar package referenced in the program, there are methods to call some dll files through the JNI mechanism, but this was not specified in the process of configuring and generating EXE. When Configure Java invocation, you need to add the directory where the dll is located in the native libraries.

How to generate exe executable file in Java

3. When executing the EXE file, java.lang.UnsupportedClassVersionError

How to generate exe executable file in Java

## is prompted.
#This is usually caused by the inconsistency between the runtime JDK version and the developed JDK version (for example, you use a 64-bit JDK when developing, but when running on other computers, its JDK lacks the 32-bit version). Both sides Just make sure the number of JDKs is the same.

The above is the detailed content of How to generate exe executable file in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete