Get started with JavaSE 2: Java Development Preparation Basics
1. Java language Overview
Java is an object-oriented programming language that can write cross-platform applications. Java technology has excellent versatility, efficiency, and Platform
Portability and security: It is widely used in PCs, data centers, game consoles, scientific supercomputers, mobile phones and the Internet, and has the largest
Developer community.
Java consists of four aspects:
(1) Java programming language, that is, syntax.
(2) Java file format, that is, the suffix of various folders and files.
(3) the Java Virtual Machine (JVM) is the interpreter that processes the *. class file.
(4) Java application interface (Java API ).
2. Java platform version
JavaSE (Java 2 Platform Standard Edition) Standard Edition
Is a solution for developing common desktop and business applications. This technology system is the basis of the other two and can complete some desktop applications.
Development.
JavaME (Java 2 Platform Micro Edition) small Edition
Is a solution for developing electronic consumption products and embedded devices.
Java EE (Java 2 Platform Enterprise Edition) Enterprise Edition
Is a set of solutions for developing applications in an enterprise environment. The technologies included in this technology system, such as Servlet and Jsp, are mainly used
Web application development.
Java features
(1) Simplicity
Java is an object-oriented language. It provides the most basic methods to complete specified tasks. You only need to understand some basic concepts and use
It compiles applications suitable for various situations. Java skips the fuzzy concepts such as operator overloading and multi-inheritance, and implements automatic garbage collection
Greatly simplifies the memory management of program designers.
(2) Object-oriented
Java is designed to focus on objects and interfaces. It provides simple class mechanisms and dynamic interface models. The object encapsulates its state variables
And corresponding methods to achieve modularity and Information Hiding. classes provide prototype of a class object, and through the Inheritance Mechanism, sub-classes can use
Method To achieve code reuse.
(3) Distributed Processing
Java is a network-oriented language. The class library provided by it can process the TCP/IP protocol, and users can easily access it through the URL address on the network.
Its object.
(4) structure neutral
The Java interpreter generates bytecode instructions unrelated to the architecture. Once the Java runtime system is installed, the Java program can run on any processor.
Line. These bytecode commands correspond to the representation in the Java Virtual Machine. After obtaining the bytecode, the Java interpreter converts the bytecode so that it can run on different platforms.
Line.
(5) Open Source
Java is an open-source language. We can see other people's Java code.
(6) cross-platform
Platform-independent features allow Java programs to be easily transplanted to different machines on the network. At the same time, Java class libraries also implement
To port these class libraries. In addition, the Java compiler is implemented by the Java language, and the Java runtime system is implemented by standard C, which makes the Java system itself
It is also portable.
(7) Explanatory
The Java interpreter directly interprets and executes the Java bytecode. The bytecode itself carries a lot of compilation information, making the connection process easier.
(8) High Performance
Unlike other languages that explain execution, such as BASIC and TCL, Java bytecode is designed to make it easy to directly convert to a machine on a specific CPU.
To obtain high performance.
(9) Multithreading
The multithreading mechanism enables applications to execute in parallel, and the synchronization mechanism ensures correct operations on shared data. By using multithreading, the program designer can
Instead of using a global event Loop Mechanism, you can easily implement real-time interaction on the network.
Yes.
(10) Dynamic
The Design of ava makes it suitable for a constantly evolving environment. You can freely add new methods and instance variables in the class library without affecting your program.
Run. In addition, Java supports multi-inheritance through interfaces, making it more flexible and scalable than strict class inheritance.
(11) Security
Java used in networks and distributed environments must prevent virus intrusion. Java does not support pointers. All accesses to the memory must be changed through the instance of the object.
To prevent the programmer from using the "Trojan" and other spoofing means to access the Private Members of the object, but also to avoid the prone errors in Pointer operations.
Error.
4. cross-platform Java
Applications written in Java can run on different system platforms. To run a java application
Install a Java Virtual Machine (JVM Java Virtual Machine. JVM is responsible for running Java programs in this system. Let's look at a graph.
Solution:
With JVM, the same Java program can be executed in three different operating systems. In this way, Java programs are implemented across platforms.
Java has good portability. Note: the Java language is cross-platform, and the JVM is not cross-platform.
V. roles and relationships of JDK, JRE, and JVM
JRE (Java Runtime Environment): includes
If you want to run a developed Java program, you only need to install JRE on the computer. That is, JRE: JVM + class library.
JDK (Java Development Kit): JDK is provided to Java developers, including java developers.
And JRE. Therefore, if JDK is installed, you do not need to install JRE separately. The development tool: compilation tool (javac.exe) Packaging Tool
(Jar.exe. That is, JDK: the development tool of JRE + JAVA.
Why does JDK contain a JRE?
First, the developed program always needs to run to see the effect.
Second, and most importantly, the development tools in JDK are actually applications written in java. They are packaged into exe files for ease of use, such
Without JRE, these tools cannot run.
The relationship between the three is simply that the java program developed with JDK is handed over to JRE for running, and the JVM ensures cross-platform.
6. Download and install JDK
Download
(1) Open the Oracle Official Website: http://www.oracle.com
(2) Click Downloads and select Java for Developers.
(3) Select Downloads and Java SE
(4) download different JDK versions for different operating systems to identify computer operating systems
Install
Remember the path you have installed during installation. My installation path is: E: \ Java \ develop \ jdk1.8.0 _ 25
Seven HelloWorld Cases
(1) Open the bin directory in E: \ Java \ develop \ jdk1.8.0 _ 25. We can see a lot of Application Files, two of which we need to make
Use javac.exeand java.exe.
(2) Compile the java source code program with the extension. java. Create a notepad file in this folder, write the following code, and
This file is saved as a file in HelloWorld. java format. Because only the current directory contains javac and java, the Java source file is now saved in
The current directory.
public class HelloWorld{ public static void main(String[ ] args) System.out.println("Hello World"); }}
(3) Open DOS and run the cd command to enter the specified folder: E: \ Java \ develop \ jdk1.8.0 _ 25 \ bin.
(4) In command line mode, enter the javac command to compile the source code to generate a bytecode file.
Format: javac HelloWorld. java
(5) If no error message is reported after compilation, enter the java command to explain and run the class bytecode file. You do not need to add. class extension during execution.
Name.
Format: java HelloWorld
Finally, we use graphs to explain how Java programs run and work: