Java Learning Notes

Source: Internet
Author: User

1. How Java works, packages, jar archive files, and deployment

    • The simplest, source---compiler---Output->java virtual machine (JVM).
Javac Party.javajava Party
    • Separating the source code from the class file, the source code (. java) is stored in the sources directory, and the output (. Class) is generated in the classes directory.
CD myproject/-D. /classes *. JAVACD MyProject/Classesjava MyApp
    • The package into the Jar,jar is javaarchive, which is a PKZIP-formatted file that can wrap a set of class files and only need a JAR file for delivery. The executable JAR on behalf of the user does not need to extract the files to be able to run. The program can be executed in case the class file is saved in the JAR. The trick is to create a manifest file with a JAR of information that tells the Java virtual machine which class contains the main () method.
CD myproject/-cvmf manifest.txt apptest.jar *-cvmf manifest.txt Apptest.jar myapp.class

Where the Manifest.txt file is placed in the classes directory, the contents are as follows:

Main-class:myapp

A Java virtual machine can load a class from a JAR and invoke the main () method of that class. In fact, the entire application can be wrapped in a JAR. Once the main () method starts executing, the Java virtual machine does not care where the class comes from, as long as it can be found on the line. One source is all JAR files that classpath the specified location. If you see a jar, the Java virtual machine queries the jar when it needs the class.

Depending on how the operating system is dynamically set, it is possible to simply double-click the JAR to begin execution, as is the case with Windows and Mac OS x. You can do this by clicking the JAR and asking the OS to open with the "Open with ..." type.

2.

Resources:

1. Kathy Sierra/bert Bates. "Head First Java"

Java Learning Notes

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.