has been writing Java programs after the console Javac--and Java commands run, or run in eclipse, today suddenly want to how can write a project anywhere can run it? So the online search steps, followed by a step-by-step realization, here to record
Tools: Eclipse
Exe4j
1. First use the features provided by Eclipse to package the project into a jar package
1) Right-click on the item you want to package
2) Select Export
3) Java--Runnable JAR file----and Next
4) in export destination: Select the path you want
Select package required libraries into generated JAR-->finish
Here: A jar package can be run, but if you want to run it or you need to go through the console output command
Java-jar Lucky_day.jar//Lucky_day The name of the packaged jar file
Note: The project here needs to be run first.
2. Use EXE4J to package the packaged jar file into an EXE file that can be executed by mouse click
1) Run exe4j--and Next
2) JAR in EXE mode----Next
3) Short name of your application: a packaged EXE file named
Output directory: To package EXE files there---> Next
4) If it is console select Console Spplication depending on the situation
Executable name: executable exe file names
You can also select the last EXE file icon
--Next
5) Click on the small green dots on the right side of the Class path to add the jar files that need to be packaged
Entry Type Select Archive
Main class Select Good
Next
6) Fill in the highest and lowest version of the JRE
Select Search sequence to delete all of the items and copy the installed JRE directory to the directory where the JRE (the copied directory) will be added under the path to be packaged (in order to run the program on a computer that does not have a JRE installed)
7) Client hotspot VM
Right behind, next to the end.
Let's see for a moment
Package Java project as executable (EXE)