Getting the basics of the Java environment to build

1, the characteristics of the java language
object-oriented, simple, cross-platform
2, into a computer to execute mechanisms
① compilation execution: The source file is compiled into machine code files (.exe), machine code directly executable file
advantages - implementation rate drawbacks - can not be cross-platform, maintenance problems
② interpreted: the translation of each source file line by line into machine code and then execute
the advantages - cross-platform, easy maintenance missing - low efficiency
3, java operating mechanism
of the Java language using interpreted after the first compilation mechanisms: the source file ( .java) file compiled into bytecode ( .class), and then be interpreted bytecode file advantages: high efficiency, cross-platform
4, the JVM (the Java Vitual machine)
the Java virtual machine, used to mask the differences between the underlying operating system
. 5, the JRE (JavaRuntimeEnvironment)
Java runtime environment = JVM + interpreter
. 6, the JDK (the Java development Kit)
Java development environment = JRE + compiler + library + development Kit
7, JDK installation
http: //www.oracle.com -> download-> Java-> javaSE
environment variable configuration ↓
the JAVA_HOME JDK installation root;
the pATH the JDK root (the JAVA_HOME%%) \ bin;
the cLASSPATH classpath
8, category
class The basic organizational unit)

    class helloWord {    //定义类名
        public static void main(String[] args) {  //主函数
            System.out.print("Hello World!");  //控制台输出语句
    }
}

9, Java compiler and run
to be done at the command prompt (Open: win + R key, type "CMD" Enter, go to the directory where the java file)

 	javac 源文件名称.java  //编译
    java  类名  //运行

10, Public class
public class // class name and file name of the same source required; a source file, there are up to a common class
11, including the
package
for managing bytecode (.class) file; writing in the first source file line
with a package to compile: javac -d source file name .java.
with white run:. java package name of the class name
to compile and run remains to be done at the command prompt,
12, notes
single-line comments: // single line comment content
multi-line comments: / multi-line comments content /
document annotation (to generate an external API documentation: Javadoc -d. .java): / * comment * document /
13, identifier naming
letters, numbers, _ and $ composition, can not start with a number; the key can not be word reserved word the same name;
14, an identifier naming
the class name: the first letter of the first word capitalized, also capitalized the first letter of the word follow
the function name: the first letter lowercase, follow the first word of the first letter of the word is also capitalized
variable name: ditto
constant name: ALL cAPS
package name: All lowercase

Released four original articles · won praise 3 · Views 182

Guess you like

Origin blog.csdn.net/qq_44664231/article/details/104639164