Home > Java > javaTutorial > 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

黄舟
Release: 2017-03-27 10:47:05
Original
2528 people have browsed it

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包的名字] [需要打包的文件]
Copy after login

Execute the main method in the jar package

java -jar ****.jar
Copy after login

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]”表示传入的参数;
Copy after login

Directly run the main method specified in MANIFEST.MF:

java -jar mplus-service-jar-with-dependencies.jar
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template