Eclipse generates a Java executable jar package with an external jar package

Source: Internet
Author: User

Previously wrote an article about usingEclipse generates the Java executable jar package, but the most recent use is unsuccessful in any case, and when you double-click the executed jar, the following error pops up:Could not find the main class:mailTest.SendMailTest1.Program wil exit

In response to this problem, I first thought about the last time I wrote the Java Chat applet packaging, and this was the error, when the web said that need to change the JDK version of the project in Eclipse is 1.6,

Although it is expected, but still some regret, so the modified jar package, when the double-click execution still pops up the error of Figure 1, and then after searching the Internet, found a correct step, but also know that the previous method packaging is not successful reasons. (However, this time when packaging, the discovery must be changed to 1.6 to succeed, and the last is not the same)
The reason for this is that the previous method is not referencing the external package, and here is the mail package that refers to the email.
The correct steps are as follows: 1, mouse Right click on the project-"Select export--" Select java--"Select Jar file--" Click next--"Select the storage path of the jar package to be generated,

--"Click on next--" to continue next (if necessary, you can remove the top two options in the interface that appears here)--"in the interface operation that appears:

Tick the arrow 1, and then select enter "/project name/file name" in the back of manifest file-click Finish, then you will see a file in the project, if you do not see, refresh the project should be able to see:

2. Open the file you just generated, such as SendMailTest1 here, add two lines inside: The full path of the class where the Main-class:main method is located Class-path: The path of the external jar package
Because this file is generated by itself and writes a line, there are three rows in the file after adding the top two lines:
It should be noted here that I started by this step out of the jar execution is still the error of Figure 1, and then after a long time to know that I write the two lines of data when there is no space behind the colon, so here must be a space.
3. After saving the top file, perform the first steps:Mouse Right click on the project-"Select export--" Select java--"Select Jar file--" Click next--"Select the storage path of the jar package to be generated -click on next--" Continue next (You can remove the top two options in the interface that appears if necessary)--"in the interface operation that appears:

Different from the previous selection, you need to check the point of the arrow 1, and then after manifest file Select the file just generated and modified-"Click Finish,jar Build Success.
I this small program of the main method to achieve a very simple function, double-click Send an email to my QQ mailbox, as long as I received the proof of success:



Eclipse generates a Java executable jar package with an external jar package

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.