Java-jar Execution jar Package appears java.lang.NoClassDefFoundError

Source: Internet
Author: User

I use the idea tool to make my own Java program into an executable jar package, of course, with eclipse or directly with the jar command line does not matter, the essence is to archive the program to a compressed package, and accompanied by a description of the manifest file.

The operation of the jar is actually very simple, a lot of information on the web, even if the error tool will be prompted, and the implementation of packaged jars is prone to some small problems, these small problems are often the jar package in the inventory file written in some small details caused.

For example, I mentioned in the title of the execution jar throws Java.lang.NoClassDefFoundError exception, can not find the class under such a package, this time do not see, is the manifest file in the Classpath writing problem:

Classpath has the following easy-to-ignore issues:

(1) where there can be no blank lines and spaces the first line may not be a blank line (the first row of the row can not have a blank line), between the row and the row cannot have a blank line, the line end of line can not have spaces

(2) Be sure to have a blank line where the last line is empty (add a carriage return after you have finished your content)

(3) where there must be a space

Wait a minute. These in fact with third-party tools (non-JDK comes with) will not have problems, and I have encountered a problem, I would like to specifically explain here, I refer to online posts, with idea to play jar, third-party jar all into the Lib folder, this time, The jar package corresponding to the classpath of the manifest file must be prefixed with the "lib\", and the problem is here, when he writes Lib\xxx-xx.jar executes the jar package, there is a Java.lang.NoClassDefFoundError exception in the header. I repeatedly and the packing list file, godless a night to climb out of the pit, need to use the "/" symbol, the classpath should be Lib/xxx-xx.jar

Java-jar Execution jar Package appears java.lang.NoClassDefFoundError

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.