Java Fundamentals 01

Source: Internet
Author: User

One. A brief history of Java development

The 1995 Java language was unveiled.

1998 release of JDK 1.2, with Java divided into J2SE, EE and J2ME

2002 release of JDK 1.4.

2004 release of JDK 1.5, introducing a number of new features: generics, annotation, and so on.

In December 2006, Sun released JDK 1.6.

In July 2011, Oracle released Java 7.

In March 2014, Oracle released Java 8.

In September 2017, Oracle released Java 9.

Two. The mechanism of Java

1. JVM mechanism

Ensures the cross-platform nature of Java programs

2. Garbage collection mechanism

Ensures a more secure and efficient Java program

Three. Building a Java environment

1. Install JDK, this is easy to get to, do not repeat

2. Configure Environment variables

PATH:JDK installation path/bin. This is to allow the system to find the execution instructions to compile and run the Java program. Because the bin directory contains most of the commands we need to use, such as Javac Java Javadoc

CLASSPATH: Specifies the search path for the bytecode file. The JVM is searching for the class file to execute from the path specified by Classpath. jdk1.4 and previous versions must be configured with this environment variable. Starting with jdk1.5, if the system does not configure this environment variable, it will default to the current directory and Java's system classpath.

Four. The smallest unit of Java program is the class

[Modifier] class [class name] {} class name as long as it is a valid identifier, but in fact we should be standardized for the class name is one or more meaningful words, and the first letter of each word is capitalized.

Five. Two steps to run a program

First, the Java source file naming is a regular: (1). Must be in. java as the suffix name. (2) If the public class is defined in the source file, the file name must be the same as the public class name. (3) If there is no public class, the file name is arbitrary.

1. Compile the *.java source file into a *.class bytecode file using the Javac command. The command is as follows

javac-d [Catalog] Java source files

directory specifies where the generated bytecode files are stored

Note: The generated bytecode file name is always the class name. If n classes are defined in a source file, N. class files are generated

2. Run with Java commands

JAVA-CP [Directory] Java class name

The directory specifies where the JVM is going to search for the Java class to execute.

Note: If there is no CP option, the search is based on the path specified by Classpath. If even classpath is not set, then the jdk1.5 and later versions will be searched in the current directory.

Six. Identifiers in Java

Custom, consisting of uppercase and lowercase letters, numbers, _, and $. Numbers cannot be preceded, cannot be used with keywords, are strictly case-sensitive

Seven. Comments

Does not have any impact on the nature of the program, mainly to help developers record ancillary information.

1. Single-line Comment://

2. Multi-line Comment:/*.....*/

3. Documentation Notes:/**.......*/

Document annotations are only valid until the class, method, Filed, inner class are placed.

You can use the Javadoc command to extract document annotations and generate API documentation from this:

javadoc-d [Catalog] Java source files

directory specifies where the document is generated

Java Fundamentals 01

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.