A. Export runnable jar
1. Eclipse Export selects the runnable jar, selects the main entry function executed, executes the Java-jar Test.jar,jar package contains the manifest file, records the referenced jar package and the class that contains the main function to be executed.
2. If the above operation generates a Test.jar and a test_lib folder containing all referenced third-party libraries, the jar package sibling directory is placed in the bat file that writes the command, and the execution gets
@echo off
Title Test
echo Start exe
Java-jar Hello.jar
Pause
3. This kind of method is relatively simple without brain, where the manifest file inside the jar package is as follows
B. Exporting a common jar
1. Eclipse is exported as a normal jar, this time does not specify a specific main entry, when a jar contains multiple portals and represents different functions, you can modify the bat file to enter different portals.
2. bat in this way can specify a class for a main function without unpacking the jar package to modify the manifest file
Obviously, the former is simpler when there is only one main function that needs to be used, while the latter is more extensible, and is used when a jar package provides a variety of features that you do not want to package separately.
"Go" bat two ways to start executing the main method in a Java JAR file