Java implements the installable exe program, and java implements the exe program

Source: Internet
Author: User

Java implements the installable exe program, and java implements the exe program

Java implements installable exe programs

The general idea of implementing installable exe files by writing Java code is as follows:

1. Create a java project in eclipse, write Java code, and export the compiled Java project to a jar package in. jar format;

2. Install the exe4jsoftware to generate the exported. jarformat file into an executable file in the. exe format. (Note: the. exe file in the specified directory is only executable and cannot be installed );

3. Install the Inno setupsoftware to generate executable. exegex file. jargex files into an installable. EXE file;

4. Note: The paths selected in exe4j and Inno setup are relative paths. Therefore, during the execution of exported jar packages, exe4j, Inno setup, and other software, we strongly recommend that you keep operations and output files in a folder;

The general steps for implementing installable exe files using java code are as follows:

1. Create a java project, write the java code, and export the jar package:

1. Create a java project and write java code;

2. Export the jar package:

Step 1:

 

Step 2:

Step 3:

2. Install the exe4j software to make the jar package into an executable exe file (note: the exe file can only be executed, but cannot be installed ):

1. Download The exe4j software and install it properly:

2. Step 1:

3. Step 2:

4. Step 3: When selecting a file, you must select the file folder containing jars and other jress. This is also the path of the output file in the. exe format. We strongly recommend that you write the file like this;

5. Step 4: Fill in the file name of the file output in the. exe format;

6. Step 5: add the jar package exported by the project. Note that the jar package of the exported jar package must be relative. For example, the path of the file in the output. EXE format is the path of the folder where the jar package is located, that is, the exe4j software workspace is the path of the jar package. The relative path is relative to the workspace, because the jar package is under the root directory of the workspace, therefore, only the file name + format of the jar package can be written;

7. Step 6: select the first java class to be executed when the project is executed, similar to setting access to the home page when accessing a project in the BS project;

8. Step 7: Set the jar package of the project and the first class for Project access, and click next;

9. Step 8: Use exe4jto create a 32-bit OS file. If you want to create a 64-bit OS file, select Settings;

10. Step 9: Set the jre version range when the program is running;

11. Step 10: because a java project is created, the project will eventually run on jvm. If you want to install jdk by yourself, it is very inconvenient to configure environment variables, therefore, jre can be encapsulated during the production process. You can set the version of the jre environment to make it easier for users to use the program. This is the step for setting the Jre runtime environment for the program: note: The jre should be placed in the same directory as the jar package, so that the relative directory can be written; otherwise, files may easily appear;

12. Step 11: Click next by default:

3. Install the Inno setupsoftware to seal the executable. exefile. jar file. jrefile to an executable. EXE file:

1. Install the Inno setup software and start the software:

2. Click next by default:

3. Set the default installation folder and version number when installing the program:

4. Click next by default:

5. Select the directory of the executable. EXE file:

6. Add the executable. EXE files, jar packages, and jre files in the folder, and add all the files in the folder. You can set the file to a relative path:

7. Click next by default:

8. Create 1.txt00002.txt00003.txt text files in the file folder of the. exefile jar package, and set them in sequence. I do not know the specific reason. It may be because I want to store some information during the running process:

9. Click next by default:

10. You can set to output the file name of the installable. exeformat file in the same format as the output file. Note: The output location of the installable. exeformat file must also be the folder where the jar package uses the jrefile to execute the. exe file;

11. Click next directly by default. Follow the steps on the image to proceed:

After the installation is complete in 122.16.aliyun.com, you can now download the. exe file that can be installed:

13. At the end of the day, compress the folder of the. exefile that can be installed in the jarnet jrefile into a package and send the package to the user. You can click the installable. EXE file to uncompress the file. After installation, you can delete the extracted file;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.