Java Project export as jar package + export Third party jar + use command line Invoke + Pass

Source: Internet
Author: User

Java Project export as jar package + export third-party jar + use command-line Invoke + Pass-through, package

Scenario 1: You do not need to pass parameters to the program, and the program does not use third-party jar packages

Export jar on eclipse:

Then select a Java file to be used as the storage, with main () Main function:

Scenario 2: parameters are passed to the program, and the program does not use a third-party jar package

In this case packaging and Case 1 are the same

Scenario 3: The program uses a third-party jar package

In this case, packaging is more complex, you need to export the third-party jar package, you can use the Eclipse plug-in fat jar, it is simple, but the fat jar only supports Eclipse 4.3 and the following version, the new version of Eclipse will not be loaded;

Second, use the command line call (or call in the bat file)

1. No reference

Open the directory where the jar package is located, enter Java-jar Xxx.jar

2. Have a reference

Open the directory where the jar package is entered Java-jar xxx.jar parameter 1 parameter 2 ... (separated by a space between parameters)

Corresponding to the main function:

 Public Static void  = args[0]; //     String targetpath = args[1];   parameter 2  }

Java Project export as jar package + export Third party jar + use command line Invoke + Pass

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.