Zhang Xiaoxiang's first lecture on Java and Zhang Xiaoxiang's first lecture on java
I. Java features: a compilation and running time everywhere.
C language execution in windows: c source program (. C) --> compile windowsexecutable file (.exe) --> windows Operating System
Java language: Java source file --> compile a Java bytecode file (. class) --> JVM Virtual Machine (can directly explain the Java bytecode CPU) -- execute the corresponding bytecode program in different operating systems
|
In windows and Linux
Bytecode program
Ii. Java Connotation
1. It is a programming language (java source file)
2. It is a development tool (compiled into bytecode files)
3. It is a running environment (JVM virtual machine)
3. Development Environment Construction
1. JDK: Development Tool: Javac (Compilation) and basic core class development environment: Java (interpretation and execution) and basic core class
2. J2Se (standard development) J2Se (Mobile Application Development)
Iv. environment variable settings
1. set command: view all environment variables (my computer-system properties-environment variables (including user variables and system variables) if the user variable name = system variable name = user variable value + system variable value)
2. set environment variable name: view the value of an environment variable
3. set xx = a set environment variable set xx = NULL cancel environment variable (only valid for the current command line window)
4. Append content a to the environment variable path and copy the existing value of path; + new value B and set % path %; + New Value % path % -- original path value (note = spaces are not allowed between left and right)
5. When setting system variables, the opened command line window is not affected, and the user variable setting can be started only after the computer is restarted.
6. When executing the java command, first find the current -- path variable
7. When multiple jdks are installed in the system: the java-verbose file loading process is printed in the command line window in detail.
5. Experience the Java Programming process
1 public class Test // a java source file can only have one public class and the class name is the same as the source file name 2 {3 public static void main (String [] args) // The main function in the class is used to execute the program. Each class can have a main function 4 {5 System. out. println ("Hello World! "); 6} 7} 8 9 class Test110 {11 public static void main (String [] args) 12 {13 System. out. print (" Hello World2! "); 14} 15} 16
1. javac Test. java compiles the Test. class and Test1.class bytecode files. A java source file can have multiple classes, and each class can compile the corresponding bytecode files.
2. If an error is reported during compilation: The file xx cannot be found, check whether the source file extension is correct (insert the file into the running window or the command line window to inspect the file extension)
3. set classpath = ''+; do not add points: do not check the current directory add points. Check the current directory classpath. Specify the java Virtual Machine search directory. path indicates the java compilation directory.
4. The current directory contains classpath: set classpath = xx ;.
5. Do not place the source file in a folder with spaces in the directory name.
Vi. running process of JVM virtual machines
1. Code Loading
2. Code Verification
3. Code Execution