"Go" bat two ways to start executing the main method in a Java JAR file

Source: Internet
Author: User
A. Export runnable jar

1. Eclipse Export selects the runnable jar, selects the main entry function executed, executes the Java-jar Test.jar,jar package contains the manifest file, records the referenced jar package and the class that contains the main function to be executed.

2. If the above operation generates a Test.jar and a test_lib folder containing all referenced third-party libraries, the jar package sibling directory is placed in the bat file that writes the command, and the execution gets

@echo off
Title Test
echo Start exe
Java-jar Hello.jar
Pause


3. This kind of method is relatively simple without brain, where the manifest file inside the jar package is as follows

B. Exporting a common jar


1. Eclipse is exported as a normal jar, this time does not specify a specific main entry, when a jar contains multiple portals and represents different functions, you can modify the bat file to enter different portals.
2. bat in this way can specify a class for a main function without unpacking the jar package to modify the manifest file

Obviously, the former is simpler when there is only one main function that needs to be used, while the latter is more extensible, and is used when a jar package provides a variety of features that you do not want to package separately.

"Go" bat two ways to start executing the main method in a Java JAR file

Related Article

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.