Java method for referencing a third-party jar package when making a jar package _java

Source: Internet
Author: User

I used eclipse packaging, but reported that there was no master list attribute error in the Activemq.jar when the cmd window was executed.

Search on the Internet, this is related to the MANIFEST.MF file, the file does not define the main method in the class path, the use of good pressure to open the jar package, and sure enough. There's only one line inside.

manifest-version:1.0

You need to add Main-class. In this example, add the following:

Main-class:com.luoluo.testuse.activemq.activemqstatemain

Above, there are a few points to note:

1. Main-class: And Com.luoluo.TestUse.activemq.ActiveMQStateMain must have a space between, remember.

2. COM.LUOLUO.TESTUSE.ACTIVEMQ is the package name of the class, Activemqstatemain is the class name where the main method is located, note: You don't need to add. java or. class.

3. If you do not refer to a Third-party package, you need to enter the cursor to the next line. Otherwise, it will be reported that "there is no master manifest attribute" error in Activemq.jar. If a third party package is referenced, enter after the Class-path, in short, after specifying the relevant parameters, you need to return the cursor to the next line.

The above only defines the main class, and if a third party package is referenced, the following error is reported:

Exception in thread "main" Java.lang.noclassdeffounderror:org/apache/activemq/broker/jmx/brokerviewmbean
In this case, you need to define Class-path in the MANIFEST.MF file. In this example, add the following:

Class-path:lib/activemq-all-5.12.1.jar

Note: A space is also required between Class-path and Lib/activemq-all-5.12.1.jar.

Also, under the same level directory as the jar package, create a new Lib folder that will activemq-all-5.12.1.jar copy into it.

For example, in this case, the jar package is under C:\Users\Victor\Desktop, you need to create a new Lib folder under the C:\Users\Victor\Desktop directory and put the corresponding third package inside.

The former is a packaged jar package, which is a Lib folder with a third party jar package.

Finally, MANIFEST. The contents of the MF file are as follows:

The results of the final implementation are as follows:

The above content for you to share the Java in the production jar package to reference the Third-party jar package method, I hope you like.

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.