Do a Java snake game exe application

Hello everyone, I am Sun Bujian 1208, today to share with you: how to do a snake game exe application, I hope to bring convenience to the need of friends, but also hope to get everyone’s attention and support.

Ideas:

First you have to have a snake, ah, just play.

1. First use Java to knock a snake game program.

2. Package the Java program into a JAR file package and the JAR package into an EXE application program

After knowing the train of thought, go according to my detailed step next, can step on pit less, don’t ask me how to know!!

One, Java “knock a” snake game

Without further comment, this article will focus on the Java project to the EXE application, the Java project code in the resources I upload -Code – greedy snack. Zip

2, the project into a JAR package

How to package it as a JAR?

1. Manually type jar packages that can be executed directly (not used this time)

.

2. Use the Intellij idea tool to print a jar package that can be executed directly

1) Open the project
2) Click File – Select Project Structure, find Artifacts, click + and select JAR – Empty.

3) You can fill in the Name column with a customized Name, select the target directory of jar package generation for Output ditectory, and double-click the file to be added to the JAR package in Available Elements to add it to the jar package directory on the left, as shown in the figure:

4) Click Create Manifest, select the path to put the manifest.mf file, directly default project root directory, and click OK.

5) Click the button behind Main Class, select the Main function in the popup box to run the program, and click OK.

6) Click “Build “> “Build Artifacts” in the menu. Double-click the Build under the JAR package to be generated in the pop-up box, as shown in the figure below

7) So far, use Intellij idea to generate jar package that can be executed directly.
8) View the generated JAR package and run the JAR package.

Run the JAR package on the command line

java -jar xxx.jar
Copy the code

Package as an EXE application

Here first you have:

  • The jar packet generated above is Greedy snack. Jar

  • Tools: Exe4j, a tool to convert jars into ExEs

    Link: pan.baidu.com/s/1FlgsxJZ5… Extract code: IJDV

1) Install exe4J, open the installed exe4J, and register

Registration code: L-G782DN2D-1f1YQXX1Rv1SQd

2) Click Next and select JAVA to EXE

3) Next, fill in the custom name and the directory to generate the target file

4) Continue to Next, select the launch mode, set the program name and program icon

5) There is an option below to make the packaged program compatible with 32 – and 64-bit systems.

Check it, and then Next.

6) Then Next, until the following interface appears, start to select jar package and configuration

Add -dfile.encoding = utF-8 to the VM parameter configuration

Add the jar package

Setting the startup class

Next to configure JRE

Next Select Client VM

7) Next until the following interface

There is one more desktopSnake games 3.0.exeFile, so far we successfully made a Java snake game exe application

Do a snake game exe application, ah, is to play, to play for you!