The article directories
- 1. History of Java language:
- 2. Java language features [open source, free, pure object-oriented, cross-platform]
-
- 1. Simplicity:
- 2. Object oriented
- 3. Portability
- 4. A multithreaded
- 5. Robustness:
- 6. Security
- 3. Java loading and execution
-
- Running a Java program involves two very important phases
-
- 1. Compilation phase
- 2. Run stage [can be in other operating systems, cross-platform]
1. History of Java language:
-
The Java language was born in 1995.
-
In fact, before 1995 SUN sent James Gosling to lead a team to develop an Oak language in order to capture the smart consumer electronics market.
-
1996 :JDK1.0 is born
-
What is the JDK? Java Development Kit
- Do Java development must install a toolkit, the toolkit needs to download from the official website.
- SUN is now owned by Oracle, so you have to go to Oracle to download it. www.oracle.com
-
Java currently consists of three major pieces:
- JavasE (Java Standard Edition)
- JavaEE (Java Enterprise Edition)
- JavaME (Java Micro Edition)
- Among them, JavaSE is the foundation, and the main direction of the future is JavaEE.
2. Java language features [open source, free, pure object-oriented, cross-platform]
1. Simplicity:
- In contrast, for example, Java no longer supports multiple inheritance, while C++ supports multiple inheritance, which is more complicated
- C++ has Pointers, but Java hides the concept of Pointers.
- So Java is relatively simple.
- The Java language is implemented at the bottom by c++. It’s not C.
2. Object oriented
- Java is purely object-oriented. More in tune with the way people think. Easier to understand.
3. Portability
-
What is portability?
- Java programs can compile once and run anywhere.
- That means Java programs can run on Windows,
- Without any modifications, the same Java application can run directly on the INUX operating system, which is called Java application portability, or cross-platform.
-
The Windows operating system kernel and the Linux operating system kernel are certainly different, and the two operating systems execute instructions differently.
-
Conclusion: Clearly, Java programs cannot directly interact with the operating system. Because there’s only one Java program. Operating systems operate differently.
-
The team at SUN came up with a solution. They had Java programs running on a virtual computer called a virtual computer
The Java virtual machine
, hereinafter referred to asJVM
.The Java virtual machine
And then dealing with the underlying operating system.
4. A multithreaded
5. Robustness:
- It has to do with automatic garbage collection
gc
Mechanism. - Garbage generated during the running of the Java language is collected automatically and does not need to be cared about by the programmer.
6. Security
3. Java loading and execution
Running a Java program involves two very important phases
- Compilation phase
- Operation phase
1. Compilation phase
-
In the compilation phase, the main task is to check whether the Java source program complies with the Java syntax. If the Java source program complies with the Java syntax, normal bytecode files (xxx.class) can be generated. If the Java source program does not comply with the Java syntax rules, bytecode files cannot be generated
-
Bytecode files are not pure binaries and cannot be executed directly in the operating system.
-
The process of the compile phase:
- The programmer needs to create a new one somewhere on the hard drive
.java
Extension of the file, the file is calledJava source files, which is written in the source fileJava source code/source program
. And this source program is not written at will, must conform toJava syntax rules <Java syntax rules are memorized >
- Java programmers need to use
JDK
Built-injavac.exe
Command for the Java programcompile.
- The programmer needs to create a new one somewhere on the hard drive
-
How do I use Javac? Where is it used?
- Javac Usage rule: Javac Path of the Java source file
- Used in the Dos command window. Javac is a Java compiler tool/command.
-
A single Java source file can be compiled to generate multiple. Class files.
-
The bytecode file /class file is the final file to execute, so the Java source file deletion after the class file is generated does not affect the execution of the Java program. However, the general Java source program should not be deleted, because the final execution effect of the class file may not be what we want, then we need to go back to modify the Java source program, and then recompile the Java source program to generate a new class file, and then run the class program to generate a new effect.
-
After compiling, you can copy the class file to run on other operating systems. [Cross-platform]
2. Run stage [can be in other operating systems, cross-platform]
-
After the JDK is installed, in addition to the javac.exe, there is another tool/command called java.exe, which is mainly responsible for the run phase.
-
Where is java.exe used? How does it work?
-
Used in a Dos window.
-
How to use java.exe? The Java class name
- Such as:
- There’s one on the hard drive
A.class
, then use it like this:java A
- There’s one on the hard drive
B.class
, then use it like this:java B
- There’s one on the hard drive
C.class
, then use it like this:java C
- Don’t write like this:
java A.class
【That’s the wrong way to do it. Just remember that】
-
-
The run-time process is:
- Open the Dos command window and enter:
java A
java.exe
The command starts the Java virtual machine (JVM
),JVM
The class loader is launchedclassLoader
ClassLoader
I’ll search the hard driveA.class
File, and the bytecode file is loaded toJVM
In the middle.JVM
willA.class
Bytecode files are interpreted as binary1010101010
Data like this.- The operating system then executes the binary and interacts with the underlying hardware platform.
- Open the Dos command window and enter: