Now I've written a Java project and want to export the executable jar file. There are two methods, as follows.
I. Runnable JAR File
Click the "File" button in the upper left corner of Eclipse and select "Export".
Select "Runnable JAR File" under Java and click "Next".
Direct "Finish".
II. JAR File
File>export.
Select "JAR File" under Java and click "Next".
Click "Next".
Click "Next".
Select the file where the main function is located and click "Finish".
How to execute the jar.
The command line can be run via Java-jar < filename >.jar;
If there is no graphical interface, it can only be run in the command line mode;
If you do a GUI, you can run it directly by double-clicking.
What happens if the export jar file does not select the main function.
the difference between jar file and runnable jar file.
The runnable jar contains a MANIFEST. MF file, which defines the Main class to being executed when the jar is run. The "Main-class" must be defined and the Java runtime knows which Class to call when the jar is "run."
If a jar does not include a manifest with the "Main-class:" It's not considered a "runnable jar"-it's just a library O F Java code.
References
Https://stackoverflow.com/questions/4974693/java-eclipse-difference-between-exporting-as-a-jar-and-exporting-as-a-runnable