Use JDK to make potentially running jars

Source: Internet
Author: User

First, preface

Some parameters of the JAVA JAVAC jar


Second, JAVA files


Third, the specific operation

1.

Compile the Java file, this example path C:\Users\victor.min\Desktop\printFileName\PrintChoseFileName.java

CD C:\Users\victor.min\Desktop\printFileNamejavac *.java

A few more class files will be found under the C:\Users\victor.min\Desktop\printFileName path

2, create the corresponding structure diagram

The package in this article is Org.happymzw.PrintChoseFileName

So create a folder src/org/happymzw/, and then put the compiled printchosefilename.class file into src/org/happymzw/, the final layer structure is src/ org/happymzw/printchosefilename.class

3, write the MANIFEST.MF file of the phase, this is very important, for the executable jar

Main-class:org.happymzw.pringchosefilename in MANIFEST.MF file

Main-class a colon followed by a space, followed by the class to include the package name, or run when the hint is not found, and finally must have a line-break key, that is, the last empty line out

Then CD to C:\USERS\VICTOR.MIN\DESKTOP\PRINTFILENAME\SRC, run the jar CVFM Test.jar manifest.mf./*

Test.jar: Name is the exported jar name, you can take it yourself

MANIFEST.MF: It's just a main-class file.

./*: Refers to all class files in the subfolders of the current folder

CD C:\Users\victor.min\Desktop\printFileName\srcjar CVFM Test.jar manifest.mf./*

4. Execute jar

Run Java-jar Test.jar

Java-jar Test.jar

You can see that the program is started.

Four, PostScript

Use JDK to make potentially running jars

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.