Home  >  Article  >  Java  >  Detailed introduction to packaging java into jar and executing the main method specified in the jar package

Detailed introduction to packaging java into jar and executing the main method specified in the jar package

黄舟
黄舟Original
2017-03-27 10:47:052510browse

This article mainly introduces how to package java into an executable jar and execute the relevant information of the main method specified in the jar package. The article gives detailed sample code, which is useful to everyone. It has a certain reference value. Friends who need it can take a look below.

java is packaged into jar

jar -cvf [jar包的名字] [需要打包的文件]

Execute the main method in the jar package

java -jar ****.jar

After execution, always run the specified Main method, if there are multiple main methods in the jar, how to run the specified main method?

Try the following command:

java -classpath ****.jar ****.****.className [args]
“****.****”表示“包名”;
“className”表示“类名”;
“[args]”表示传入的参数;

Directly run the main method specified in MANIFEST.MF:

java -jar mplus-service-jar-with-dependencies.jar

Run the specified main method (there is no specified main method in MANIFEST.MF):

java -cp mplus-service-jar-with-dependencies.jar com.smbea.dubbo.bin.Console start

Summary

The above is the detailed content of Detailed introduction to packaging java into jar and executing the main method specified in the jar package. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn