Home >Java >javaTutorial >How to generate exe executable file in Java
1. Download the tool EXE4J that converts jar packages into EXE.
2. After the download is complete, follow the steps below to install EXE4J.
#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.
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.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-1p4lv7mg7savA-XVK209982F-1y0i3h5ywx2h2A-XVK267351F-dpurrhnyarvaA-XVK204432F-1kkoilo1jy2h4rA-XVK246130F-1l7msieqiwqnqA-XVK249554F-pllh451kcke50A-XVK238729F-25yn13iea25i A- XVK222711F-134h6ta8yxbm0A-XVK275016F-15wjjcbn4tpjA-XVK275016F-15wjjcbn4tpj
2. Click next and select "JAR in EXE" mode.
3. Click next and fill in the generated application name and output directory.
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.
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:## 5. Click next to add the jar that needs to generate EXE Package and set its mainclass.
When using the Java API, set the minimum and maximum version limits of the runtime jre to Adapt to different application scenarios.
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.
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.
4. 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.
2. When executing the EXE file, java.lang.UnsatisfiedLinkError is prompted
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.
## is prompted.3. When executing the EXE file, java.lang.UnsupportedClassVersionError
#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!