How to reference a third-party jar package when making a jar package

I use eclipse packaging, but when the CMD window is executed, an error "there is no main manifest attribute in activemq.jar" is reported.

I searched the Internet. This is similar to manifest MF file, which does not define the path of the class where the main method is located. Use good pressure to open the jar package. That's true. There's only one line in it

Main class needs to be added. In this example, add the following:

Above, there are several points to note:

1. Main class: and com luoluo. TestUse. activemq. There must be a space in the middle of activemqstatemain. Remember.

2. com. luoluo. TestUse. ActiveMQ is the package name of this class, and activemqstatemain is the class name where the main method is located. Note: do not add it after it Java or class。

3. If the third-party package is not referenced, press enter to move the cursor to the next line. Otherwise, the error "there is no main list attribute in activemq.jar" will still be reported. If a third-party package is referenced, press enter after class path. In short, after specifying relevant parameters, press enter to move the cursor to the next line.

The above only defines the main class. If a third-party package is referenced, the following error will be reported:

In this case, it is necessary to use manifest Class path is defined in MF file. In this example, add the following:

Note: class path and lib / activemq-all-5.12 A space is also required between 1.jar.

At the same time, under the same layer directory of the jar package, create a new lib folder and add activemq-all-5.12 1. Jar copy go inside.

For example, in this example, if the jar package is under C: \ users \ Victor \ desktop, you need to create a new lib folder under C: \ users \ Victor \ desktop directory and put the corresponding third package in it.

The former is the packaged jar package, and the latter is the Lib folder, which contains the third-party jar package.

Finally, manifest The contents in MF file are as follows:

The results of the final implementation are as follows:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>