, high-level language operating mechanism
High-level language according to the implementation of the program is divided into two types of compilation and interpretation .
The Java language is special, and the execution of a Java program must be preceded by a compilation of the steps explained.
1 compile to generate bytecode, perform interpretation only for JVM (. Class) 2JVM
The JVM:(Java Virtual Machine) is responsible for interpreting the execution bytecode files and is a critical part of the Java program's cross-platform.
Cross-platform principle: The JVM of all platforms provides the interface of the Java byte code up to the same-+, the interface to adapt to different platforms is not the same.
Tip: Windows operating systems (case-insensitive) find commands through the PATH environment variable, the Linux operating system (case-sensitive) finds a command through the PATH environment variable, and the value of the environment variable is a series of paths.
After you add an environment variable, you can run related commands in the Command window.
Compiling Java programs Javac srcfile
Run Java program Java Java class name
Basic Java Program Rules
A Java program is a purely object-oriented programming language that must exist in the form ofclasses (Class), which is the smallest program unit of a Java program. All program parts must be placed in the class definition.
The Main method is the entry for the Java program, and the Java Virtual machine interprets the execution from the main method. Public static void Main (string[] args)
In a large Java program, only one class contains the main method, and the other classes are called directly or indirectly by the main method.
Naming rules for Java source files
The primary file name of the Java source file must be the same as the class name of the public class, and a maximum of one public class can be defined in the Java source file.
garbage collection mechanism (garbage collection)
Memory leaks: The allocated memory is not recovered in time, causing the system to run down.
The JRE provides a background thread for detection control, which is automatically garbage collected when the CPU is idle or low on memory.
When no reference variable points to the memory that was originally assigned to an object, the JVM's super thread automatically frees the memory.
(See also "Java Virtual machine" For more detailed mechanisms)
Java Learning Note 1