Eclipse Create Java program executable jar Package Tutorial _java

Source: Internet
Author: User

In Eclipse, right-click on the name of the project you want to make a jar package, and the following pop-up box appears, select Export:


Second, click "Jar File" in the next interface, and then next:


Third, in the next appearance of the interface, check the items you want to package and other options, such as the test item, as shown in the figure, and then click Browse on the right arrow to select the directory where you want the jar package to be saved, and name your jar package, for example, where I choose to store on the desktop, The name is Jartest, then click "Next" and then click "Next" in the following pop-up interface:


Four, after the last step two times "next", the following interface appears, check the options shown in the previous illustration, and then click the entry of the browse selector that the arrow refers to, which is the Java Main method (you do not need this option if you are not executing a jar package):


Five, after the previous step will pop up a selection box, contains all the Mian methods in this project, if there is no main method in the program, the pop-up box does not show anything, for example, there are three main methods, I choose Jartest, and then click OK:


Six, OK after the selected jartest will appear in the text box behind MainClass, click "Finish":


After the finish, the following pop-up box appears, prompting the jar package to export successfully:


Eight, then we can see a Jartest.jar file on the desktop, if we installed the JDK on the computer and equipped with the environment variables, then double-click the file directly, the program will start from the selected Mian method:


Nine, for example, my main code for this jartest is as follows: When you run this program, you generate a file at the end of a. Log in the desktop, and then loop through it to write the five elements.


Ten, I have installed the JDK on my computer, but also with the environment variables, So you can double-click the Jartest.jar file to execute the program, and then you can see that a new file with a. Log ending has been successfully shown on the desktop, and you can also see that the inside is written to the five elements to prove that the executable jar package has been successful:

The above is the entire content of this article, I hope to help you learn.

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.