First, the operation mechanism of Java
The running mechanism of high-level language mainly has two kinds of compiling and interpreting. C + + is a compiled language that is translated by a specialized compiler for a specific operating system platform, generating executable code that is highly efficient, but not conducive to cross-platform development. Python is an interpreted language, using a dedicated interpreter to line up the source file into a specific operating system platform machine code, and immediately execute (interpretation of the language does not have a compiler, but can be considered every time the interpretation of the source code is compiled, linked, executed) this makes the source of the interpreted language can be used across platforms ( Only a different platform to install different interpreters), but less efficient. Java has a different operating mechanism than the above two, Java needs to compile but build is not a specific platform machine code, but rather to generate platform-independent bytecode, and then interpreted by the Java interpreter execution. Java can do this because of the introduction of the Java Virtual Machine (JVM) concept, each platform has its own JVM, and different JVMs have the same Java compiler-oriented interface, so the written Java source code can be directly used by the compiler to generate a different environment can explain the running bytecode.
Second, write the first Java program
1, install the JKD and configure the environment variables, this part of the previous blog on the Android development environment to build
2. Write a program using Notepad or another text tool
1 Public class HelloWorld 2 {3 Public Static void Main (string[] args) 4 {5 System.out.println ("Hello World"); 6 }7 }
Save As Helloworld.java
Then in the command line to switch to the source program directory, Javac is to compile the Java program instructions, Java is to explain the implementation of Java instructions
Here, use EditPlus instead of the command line
First configure the above two commands, select Tools-Configure custom tools, and then complete the configuration of Javac and Java commands
Then you can "tools" in the compilation of Java programs and run Java program two things, respectively, Hello World appeared.
III. Basic Rules of Java
1. Any code must appear in the form of a class
2, the Java program must be written in the entry process
public static void Main (string[] args)
{
}
3. If the public class is set in the Java source program, the primary file name must be the same as the class name. (a maximum of one public class can be defined in a Java program)
4, a Java source file only defines a class, not the same kind of definition in different source files
Getting Started with Java