This is the 10th day of my participation in the More text Challenge. For more details, see more text Challenge

How do you package your Java code into an EXE file that you can run on your computer

This article focuses on how to package the Java code we wrote into an EXE file that runs on your computer. This section only describes the method of directly packaging into exe, as to package into exe installation package in the next section

Software to prepare

  • Today we only need to use one of the software after downloading the above, yes, the exe4.exe file inside

  • And then you install the software, and it’s all foolproof. Don’t say! After installation, the home page shows, activation code to search online!

The jar package preparation

  • Of course we have to prepare the JAR before we pack it. Right-click the project –>Export–>Runnable JAR File

  • Click next and don’t forget to select the main entry, which was discussed in the previous post.

Packaging began

  • Before we start packing, we need to prepare the JRE file just like I used jsmooth to package the EXE file. I used the JDK file here, and the JRE doesn’t seem to work

  • To begin the real packaging, first we open the exe4j software that we installed earlier. Click on Step 2: Peoject Type and select JAR in EXE Mode

  • Click Next and we will see that we need to fill in the project name and the output address of the program. The project name can be anything you want to fill in, and the output address is where you want your EXE file to end. I suggest you put it where you can find it, after all, you only need to click on the EXE to run.

  • Then click Next and on the next screen we encounter the Executable Type selection, depending on our Java code, if you are developing a black form program select Console Application; If you’re developing a Java Swing program, choose the default GUI Application. The third option, I don’t know what Java program. Readers can do their own research. I’m going to go with the default GUI program.
  • The second option is Executable Name which is the name of your program and you can have a loud name for your Executable. Chinese names are supported here.
  • The third option is Icon File, which is our EXE sequence Icon, just like the QQ software that penguin, it is suggested that you can set your own personality photos, but this can only use the ICO format of the picture. Of course, you can use the default icon without selecting it

  • Once that’s set up let’s click on the left menu of the interface under Executable Info under Advanced Options, because here we need to set up some details, not something that is very difficult to successfully package.

  • Redirection parameters

  • service options

We’ll see what the parameters are, so you can set them or not set them.

  • Version info is not important here either, check out my reference

  • 32 -bit or 64 – bit

It depends on where your I project is running, if you want it to run on 64 you can select Generate 64-bit executable and check √ otherwise.

  • Mainfest Options is not selected here, let it default

  • Then it’s time to add the JAR package. (java invocaton)

  • Click the plus sign in the class path to select the JAR package we typed before

  • After selecting the JAR package, we select the Main entry we need the program to run from the Main Classs below.

  • After setting the lowest and highest version of jre, click Advanced Options–>Search Sequence. By default, the JDK in our system environment will be selected. However, the JDK in our system environment cannot be used by others. Then we added the JDK that we had prepared

  • Select Client HostPOST VM from Preferred VM after next

  • After next, we went to Splash Screen, which is your program startup interface. If you want to make something cool, you can choose it. There is no limit to the pictures here, I just chose ordinary pictures, you can also try GIF.

  • From there you can go all the way to the next step. The following screen allows you to select the Finishing or launcher.

rendering

  • Start the figure

  • After operation interface

  • The icon has changed

  • You can also right-click the exe and see that the properties are some of the things we set up above.