First, the development environment to build:
(a), introduction to the Java language:
1. Introduction to the Java language:
(1) What is Java:java is a computer programming language. It is a computer programming language, it is a software development platform, it is a software running platform, it is a software deployment environment.
(2) Java history: The Java language was first born in 1991.
(3) Java system:
JAVA SE (J2SE Standard Edition/Desktop edition)
JAVA EE (EE Enterprise Edition, building a large web site)
JAVA ME (J2ME mini version, mobile Mobile terminal)
(4) Java Development environment:
Eclipse, MyEclipse, Jcreator,workshop,netbeans,jdeveloper,intellij.
(5) Running Java programs: Running in the Java Virtual Machine (JVM), the JVM is part of the Java Runtime Environment (JRE). You can run Java programs as long as the JRE is installed on your computer.
2. Introduction to JRE and JDK:
(1) What is a JDK?
The JDK (Java development Kits) is the Java Development Toolkit, which mainly includes:
A.JRE (Java run time Environment,java runtime Environment). It is a subset of the JDK that contains the components required to execute the Java program in the JDK, but does not contain the deployed components.
B.JVM (Java virtual Machine,java vm). The main function is to run and maintain Java programs.
C.java API (Application programming Interface). The main function is to provide the programmer with the functions that have been written, so as to facilitate rapid development.
The D.java compiler (Javac.exe), the Java Runtime Interpreter (Java.exe), the Java Documentation Tool (Javadoc.exe), and other tools and resources.
(2) How to develop Java
JDK contains JRE,JRE containing JVM
Jre:java running environment, only run, cannot compile, Debug.
JDK Software Development Kit (SDK), JDK basic components include: ...
(3) The three main functions of the JRE are as follows:
A. Load code: Done by the ClassLoader (class Loader).
B. Check code: done by the bytecode Checker (bytecode Verifier).
C. Execute code: Completed by Runtime interpreter (runtime interpreter).
3. Setting Environment variables
Setting the environment variable requires the following two parameters to be configured.
(1) Path
(2) CLASSPATH
Java_home: (direct replacement) F:\SOFTWAREINSTALLATION\JAVA\JDK (I moved the JDK into the F:\SoftWareInstallation\Java\)
CLASSPATH: (direct replacement).; %java_home%\lib;%java_home%\lib\tools.jar (Note that there is a point in front)
PATH: (appended directly to the original content)%java_home%\bin;%java_home%\jre\bin
(ii) The Java Development environment is built:
Physical storage structure: Inside the Create_workspace, SRC stores the. java file, and the bin holds the. class file.
(c) Comments in Java code
(1) Class 1th: Single-line comments, starting with//, usually written in the key Java source code, do not wrap.
(2) class 2nd: Java multi-line annotation, with/*...*/enclosing the description of multiple lines, mainly on the Java program of multiple lines of code unified annotation.
(3) Class 3rd: Document comments, beginning with/**, and ending with */, such comments can be compiled by the compiler to save the document for others to review.
(iv) source text character Set
(1) Write code in Notepad, the encoding must be set to "ANSI" when saving, the full name of ANSI is American national standard Institute, that is, "American State Standards Association". To enable the computer to support more languages, you typically use the 0x80~0xff range of two bytes to represent 1 characters. For example: Chinese characters "medium" in the Chinese operating system using [0xd6, 0xD0] These two bytes to store.
(2) Different countries and regions have set different standards, resulting in GB2312, BIG5, JIS and other coding standards. These use two bytes to represent a character of a variety of Chinese character extension encoding, called ANSI encoding. In the Simplified Chinese system, the ANSI code represents the GB2312 encoding, in the Japanese system, the ANSI code represents the JIS code.
(3) UTF-8 coding is widely used in foreign countries, domestic websites and blogs more use the Simplified Chinese encoding GB2312 character set; Hong Kong, Macao and Taiwan regional websites use Traditional Chinese web page encoding BIG5 character set; UTF-8 contains simplified and Chinese characters, which can display multiple language characters correctly. In addition to foreign users if using Windows XP English version, browse UTF-8 encoded any Web page, whether Chinese, or Japanese, Korean, Arabic, can be displayed normally, UTF-8 is the world's common language encoding, and if the English version of Windows XP IE 6.0 Browse the GB2312 language-encoded Web page, you will be prompted to install the language pack. As a result, many foreign visitors may be lost.
(4) using Notepad to save the same content in UTF-8 format, Notepad will precede the file header with several invisible characters (EF BB BF), which is the so-called BOM (Byte Order Mark). The program reads an invisible character from the file (the problem is still unresolved in JDK 1.6) because Java does not correctly handle the BOM encoding of the UTF-8 file when it reads the file, and the first 3 bytes are treated as text content, so the compilation cannot pass. If the UTF-8 file is written in Java, you can read it correctly using Java.
(v) The following summary of the Java program is prepared
(1) Java source files must end with the extension. Java, the basic component of the source file is the class.
(2) The source file name must be the same as the name of the public class, and there is at most one class declaration in the source.
(3) The execution entry of the Java program is the main method, which has a fixed writing format: public static void Main (string[] args) {...}
(4) The Java language is strictly case-sensitive, and each statement ends with a semicolon (;).
(5) A space can only be a half-width or tab character.
(6) Add the appropriate code comments.
(vi) Java Class Library organizational structure and documentation
The JDK contains a number of predefined classes that can be used directly during programming to improve programming efficiency.
The help documentation for the Java API (Java application Programming Interface) describes these predefined classes in detail.
Create a test document named Helloworlddoc, as shown in the following code:
Public class Helloworlddoc {/*** Name: Zhang San * time: 2013.1.20 */publicstatic void Main (string[] args) {int number = 0= "Le know Academy"; System.out.println ("test Document");}
Execute the following command:
D:\>javadoc Helloworlddoc.java
You can generate a help document for the Helloworlddoc class. The resulting file is in the same directory as the Helloworlddoc class. If you want to better refine the resulting file, such as placing it in a folder. To use the "-D" command, the command to place the resulting help document in the Testdoc folder is as follows:
d:\>javadoc-d Testdoc Helloworlddoc.java
If the text character appears garbled in the resulting document, you can specify the character set used to avoid this garbled problem:
D:\>javadoc-encoding gbk-charset gbk-d Testdoc Helloworlddoc.java
(vii) Introduction to Java Virtual machines
The Java Virtual machine JVM is a very important part of Java programming, and in simple terms it can be referred to as the Java Runtime Environment, which can be understood as an abstract machine implemented by software simulations in real machines. It has an interpreter component that translates Java bytecode into executable code that can be recognized by the operating system.
The JVM is made up of compiled Java classes that are designed to execute Java programs. The three main tasks of a virtual machine are loader, inspection, and execution programs. The specific elaboration of each task is shown below.
(1) Class loader
(2) Byte code checker
(3) Execution procedure
The Java program executes the following procedure:
① Writing code
② compiling
③ class Loader ClassLoader
④ byte code (BYTE-CODE) checksum
⑤ Explanation (interpreter)
⑥ Run
The Java Virtual machine works as shown in compiling and running.
The execution of a Java program is divided into two stages: compile stage, run phase.
Write the Java source file, then compile the source file, form the class file, and finally run in the Java runtime. The work of the runtime is provided by the Java platform itself, and we do not need to do any work.
(eight) Java development debugging techniques and how to use Eclipse shortcut keys
How to Trace in Java after setting breakpoints: In Eclipse, add breakpoint debugging, and then press F5 (Step Into), F6 (Single step Skip), F7 (step back), F8 (next breakpoint);
(ix) Java garbage collector
In the process of running the program, the memory space on the heap is no longer used, the memory blocks are garbage to the program.
produce garbage, naturally need to clean up the rubbish, more importantly, it is necessary to recycle the memory resources occupied by these rubbish and reuse them, thus saving resources and improving system performance.
In C, C + + and other languages, the programmer is responsible for recovering useless memory, which is a complex and arduous task.
In the Java language, a garbage collection (garbage COLLECTION,GC) mechanism is provided. The garbage collection mechanism eliminates the responsibility of the programmer to reclaim useless memory space, and the Java Virtual Machine provides a system thread (that is, a garbage collector thread) to track the allocation of storage space and to check and release the storage space that can be freed during the idle time of the Java virtual machine. The garbage collector is automatically enabled during the Java program run.
(10) Java operating techniques in eclipse
(1) ctrl+l: Quick fix
Public Static void Main (string[] args) {
TODO auto-generated Method stub
int a =100L;//mouse hover at 100L, will prompt two kinds of conversion method; or press F2
}
(2) ctrl+d: Quick Delete Line
(3) Shift+enter: Fast new Next line
(4) Tab: Fast indent alignment
(5) Ctrl+f11: Quick Run Project
(6) ALT + up/down key: fast moving Line
(7) ctrl+alt+ up/down key: Quick copy Line
(8) Ctrl+m: Maximize the workspace by zooming in the view where the cursor focus is
(9) alt+/: auto-complete code
() ctrl+/: Select Multiline Comment, and then cancel comment again.
Comments can also:/** after enter
Color and font: In the right-click---preference----.
00-java Language Introduction