How to package Java source files into an executable file __java

Source: Internet
Author: User

This article is reproduced in: http://blog.163.com/dra_gon_520@126/blog/static/63456321201031411837757/

1. Centralize the prepared package of. java files into one directory such as C:\source

2. Create a directory that holds. class files such as C:\class

3. Use command javac-d class Source\*.java in C-Packing directory
Compiles all. Java source files under the source folder, and the generated. Class bytecode files are placed in the class directory

4. Execute jar CVF Abc.jar *.* in class directory
Pack all the files into Abc.jar files

5. Extract META-INF/MANIFEST.MF Files
Execute jar XFM Abc.jar META-INF/MANIFEST.MF
Just pull out the file manifest.mf
Edit this file
Join Main-class:font2dtest on the last line
Where Font2dtest is the name of the class that contains the main function in your own class
If you have a package name, you should bring the package name as test. Font2dtest

6. Update the META-INF/MANIFEST.MF file in the jar package
Execute jar UFM Abc.jar META-INF/MANIFEST.MF
Warnings can be ignored

7. Okay, now the Abc.jar can run directly.

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.