1. Download the tool EXE4J that converts jar packages into EXE.
2. After the download is complete, follow the steps below to install EXE4J.
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.
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:
4. Possible problems
# 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.
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!