Eclipse Export jar files and the difference between jar file and runnable jar filename

Source: Internet
Author: User


Now I've written a Java project and want to export the executable jar file. There are two methods, as follows.



I. Runnable JAR File


Click the "File" button in the upper left corner of Eclipse and select "Export".



Select "Runnable JAR File" under Java and click "Next".



Direct "Finish".



II. JAR File


File>export.



Select "JAR File" under Java and click "Next".



Click "Next".



Click "Next".



Select the file where the main function is located and click "Finish".



How to execute the jar.
The command line can be run via Java-jar < filename >.jar;
If there is no graphical interface, it can only be run in the command line mode;
If you do a GUI, you can run it directly by double-clicking.


What happens if the export jar file does not select the main function.



the difference between jar file and runnable jar file.


The runnable jar contains a MANIFEST. MF file, which defines the Main class to being executed when the jar is run. The "Main-class" must be defined and the Java runtime knows which Class to call when the jar is "run."
If a jar does not include a manifest with the "Main-class:" It's not considered a "runnable jar"-it's just a library O F Java code.


References


Https://stackoverflow.com/questions/4974693/java-eclipse-difference-between-exporting-as-a-jar-and-exporting-as-a-runnable


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.