How to run a jar package containing multiple main programs

Source: Internet
Author: User

In a project, there are usually more than one main program. When packaging jar files, you must specify the main program. For Maven, configure the main program as follows:

 

In pox. xml

<Build> <plugins> <plugin> <groupid> Org. apache. maven. plugins </groupid> <artifactid> Maven-shade-plugin </artifactid> <executions> <execution> <phase> package </phase> <goals> <goal> shade </ goal> </goals> <configuration> <transformers> <transformer implementation = "org. apache. maven. plugins. shade. resource. manifestresourcetransformer "> <mainclass> CN. vicky. skstatistics. money. APP: This is the main program class </mainclass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> <finalname> skmoneystatistics </finalname> </build>

 

You can double-click to run the jar program.

 

If a jar contains multiple main programs, but you do not configure the default main program, or you want to run the specified main program, run the following command:

Java-CP example03-1.0-SNAPSHOT.jar CN. Vicky. example03.helloagent

-CP <directory and Class search path for zip/jar files>

Example03-1.0-SNAPSHOT.jar jar package

Main Program class specified by CN. Vicky. example03.helloagent

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.