Original intention:
When writing some work-assisted gadgets, make them into exe for easy use
Preparation:
Eclipse,jdk,net.sf.fjep.fatjar_0.0.32.jar,exe4j.exe
1 Pack the project into a jar file:
1.1 Use Eclpise's Export function to generate jars (recommended when simply generating jar packages)
Directory structure
Right-click on the project and select Export
Leave only java files
There are two ways to deal with next to finish by default
Method 1: Automatically generate MANIFEST.MF (default)
Method 2: Write MANIFEST.MF by yourself (you can write some content you want)
illustrate:
1) The purpose of executable jar file is achieved by specifying "Main-Class".
2) In fact, we finally package the project into an exe. Class-Path can be not specified. When packaging the exe, we also need to specify the classpath.
3) Because there are dependency packages and resource files, the generated jar file will be reported.
1.2 Use the eclipse three-party plug-in fatjar to generate jar (recommended when generating exe files)
Download net.sf.fjep.fatjar_0.0.31.jar and place it in the plugins directory of Eclipse.
Right-click on the project and select Build Fat Jar
Select the external dependency jar used to select the project
Description: This jar is executable
2 Generate the project to exe file: (using the software is exe4j)
Create a folder in any directory, the name is the same as the project name, and put the file into it
Open exe4j and follow the steps:
1.welcome Skip
2. Project type
3. Application info
4.Executable info
5.Java invocation
6.JRE
Search sequence
Preferred VM
7.Splash screen,8.Messages,9.Compile executable,10.Finished
next --> finish
Note: The software used is exe4j. Be careful to register and activate (just find a registration code online), otherwise there will be a pop-up box when running the generated exe file.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.