Comprehensive Understanding of jar Problems

Source: Internet
Author: User
For more information about jar-general Linux technology-Linux programming and kernel, see the following. Public class HelloWorld
{
Public static void main (String args [])
{
System. out. println ("MainClass work well ");
SubClass mycls = new SubClass ();

}
}

Class SubClass
{
Public SubClass ()
{
System. out. println ("SubClass work well ");
}
}
Step 1: Put it under the JavaDoc directory of D:, HelloWorld. java will be available under D: \ JavaDoc, and then compile it in the console
Pass (this program is not wrong, but compilation is not passed, you need to set your java environment variables)
Compile: D: \ JavaDoc> javac HelloWorld. java
Explanation: D: \ JavaDoc> java HelloWorld
Start packaging if output exists.
1): Only HelloWorld. class SubClass. class (delete other files) is left in D: \ JavaDoc)
2): Create a META-INF folder under D: \ JavaDoc, create a new file MANIFEST. MF under the META-INF again (there is no write in it)
3): Create a MANIFEST. MF file under D: \. The content of the file is as follows:
Main-Class: HelloWorld
4): enter D: \ JavaDoc in the console and enter the packaging command
D: \ JavaDoc> jar cvfm FirstjarFile. jar ../manifest. mf *
The FirstjarFile. jar file is generated in JavaDoc. Run: java-jar firstjarfile. jar.
The result is displayed:
MainClass work well
SubClass work well

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.