The difference between the eclipse and export the jar file of runnable jar file

(1) runs directly .class method java -cp. Com.guangfa.demo1, without adding .class suffix.-Cp is an abbreviation for -classpath, other types of paths are run specified class dependent, usually library, jar package and the like, need the full path to the jar package, the window semicolon ";"

(2) from the eclipse export of jar file, only the .class packaged. Therefore, the implementation of this jar file needed java -cp;. Demo1.jar com.guangfa.demo1, if also applied to another lib library must be stated in the cp, that is  
java -cp;. Demo1.jar; lib01. jar; lib02.jar com.guangfa.demo1 to perform. demo1.jar also cp inside, demo1.jar lib is the library, the last parameter specifies the class name to be executed.

(2) If the export from the eclipse is runnable jar file, then the execution of this jar when the package is not necessary to specify what kind of direct implementation of this java -jar demo1.jar.
The reason is that different MANIFEST.MF contents of a jar package. indicate which class runnable jar packages executed first, so you can use java -jar demo1.jar to execute the code you want, without having to specify which specific classes.
You can open this jar package to see the difference between the MANIFEST.MF.

jar file                                                                                 runnable jar file  

  

 

 

 

     When generating runnable jar file, there are two options, Extract required libraries into generated JAR and package equired libraries into generated JAR. The former is used to extract the .class file, the latter is required to put all the jar packages are scored in a bag. MANIFEST.MF file contents of both are different, this should be the eclipse caused.

 

Guess you like

Origin www.cnblogs.com/wqbin/p/11128581.html