English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A Brief Introduction to Executing the main Method in a Jar Package in Java
After packaging the jar file with OneJar or Maven, use the command:
java -jar ****.jar
After execution, it always runs the specified main method. If there are multiple main methods in the jar, how do you run the specified main method?
Try the following command:
java -classpath ****.jar ****.****.className [args]
"****.****"" represents "package name";
"className" represents "class name";
"[args]" represents the parameters passed in;
Run the main method specified in MANIFEST.MF directly:
java -jar mplus-service-jar-with-dependencies.jar
Run the specified main method:
java -cp mplus-service-jar-with-dependencies.jar com.smbea.dubbo.bin.Console start
This brief introduction to executing the main method in a Java jar package is all the editor has to share with you. It is hoped that this can provide a reference for everyone and that everyone will support and cheer for the tutorial.