JAVA_Basis - 1.Introduction of java development environment

1 Introduction

The JAVA_Basis project is my summary and accumulation of java learning. Today is August 30, 2020. It is the beginning of my series of study notes. I hope I can stick to it and update one every day. Come on!

2 Overview of java language

java official website

Java is an object-oriented programming language. Its predecessor was the Oak language developed by a team led by James Gosling in the 1990s for a "green project" for them. In 1994, the Oak language was renamed the java language, and then the java language was built. The Internet Express has developed rapidly. In January 1996, Sun released the first Java Development Kit 1.0 (Java Development Kit 1.0). This was an important milestone in the development of Java and marked that Java became a An independent development tool.

Sun launched in 1995

In 1991, James Gosling of Sun Company and others began to develop Oak language

In 1994, the Oak language was renamed Java

Received the first investment of 100 million yuan in 1996

In 1998, jdk1.2 was proposed and renamed to java2

After launch jdk1.3 jdk1.4

In 2005, it was renamed jdk5.0, with substantial version improvements

In 2006, Sun announced that it would release Java as free software

Since March 2007, all developers around the world can modify the Java source code

Jdk6.0 launched in 2007

In April 2009, Oracle acquired Sun for $7.4 billion

Jdk7 was officially released by Oracle in July 2011

Java8 was officially released in March 2014

2.1 Java language classification (JavaSE, JavaEE, JavaME)

JavaSE:

Java SE lets you develop and deploy Java applications on desktops and servers. Java offers the rich user interface, performance, versatility, portability, and security that today’s applications require.

Java SE enables you to develop and deploy Java applications on desktops and servers. Java provides the rich user interface, performance, versatility, portability, and security required by today's applications.

JavaEE

Java Platform, Enterprise Edition **(Java EE) is the standard in community-driven enterprise software. Java EE is developed using the Java Community Process, with contributions from industry experts, commercial and open source organizations, Java User Groups, and countless individuals. Each release integrates new features that align with industry needs, improves application portability, and increases developer productivity.

(Java EE) is a standard Java EE development community-led enterprise software. Use the Java Community Process, with contributions from industry experts, commercial and open source organizations, Java user groups, and countless individuals. Each version integrates new features, combines industry needs, improves application portability, and improves developer productivity

JavaME:

Java Platform, Micro Edition (Java ME) provides a robust, flexible environment for applications running on embedded and mobile devices in the Internet of Things: micro-controllers, sensors, gateways, mobile phones, personal digital assistants (PDAs), TV set-top boxes, printers and more. Java ME includes flexible user interfaces, robust security, built-in network protocols, and support for networked and offline applications that can be downloaded dynamically. Applications based on Java ME are portable across many devices, yet leverage each device’s native capabilities.

(Java ME) provides a robust and flexible environment for applications running on embedded and mobile devices in the Internet of Things: microcontrollers, sensors, gateways, mobile phones, personal digital assistants (pda), TV set-top boxes, printers, etc. Wait. Java ME includes a flexible user interface, robust security, built-in network protocols, and support for dynamically downloadable network and offline applications. Java ME-based applications can be ported across many devices, while also taking advantage of the native features of each device.

2.2 Features of the Java language

2.2.1 Simplicity:

The Java language is equivalent to the subtraction of the C++ language:
A. break/continue syntax instead of the go to statement
B. Eliminate operator overload and multiple inheritance features
C. Do not use the main file, eliminating the preprocessor
D. No need Pointer
F. Automatic recovery mechanism

2.2.2 Compilability:

The Java compiler calls the program a byte-code file (byte-code), which is commonly referred to as a .Class file.

2.2.3 Explanatory:

In the process of program development, Java language reduces the process of "linking" by loading classes into the environment, and greatly improves development efficiency.

2.2.4 High performance:

Java language is compiled first and then interpreted + "just-in-time" compilation = full compilation
, that is, Java language realizes full compilation

2.2.5 Object-oriented:

Object-oriented design ideas make developers pay more attention to data and methods of manipulating data, rather than strictly thinking in terms of process
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-d1OY09n2-1598799350294)(/img/bVbL6Ro)]

2.2.5 Robustness:

A. The method declaration displayed by Java guarantees call errors when compiling the program.
B. Java does not support pointers, which eliminates the possibility of rewriting storage and corrupting data.
C. The automatic recovery mechanism eliminates errors that occur during dynamic storage allocation and contact allocation.
D. Java checks when interpreting the program

2.2.6 Security:

The Java language has no pointers, so it avoids forging pointers to point to memory.
The Java language compiler does not handle storage arrangement decisions, so the actual storage arrangement cannot be viewed through declarations. The interpreter determines the actual storage location.
The Java runtime system uses a bytecode verification process to ensure that the code loaded on the network does not violate the Java language restrictions and prevent malicious program attacks.

2.2.7 Cross-platform:

Just install a Java Virtual Machine (JVM Java Virtual Machine) on the operating system that needs to run java applications. The JVM is responsible for the running of Java programs in the system.

Because of the JVM, the same Java program can be executed on three different operating systems. In this way, the cross-platform nature of the Java program is realized. Also known as Java has good portability.
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-FLFkYhDz-1598799350299)(/img/bVbL6Ry)]

2.2.8 Distributed processing:
2.2.9 Open source:

2. JDK(Java Development Kit)

2.1 Overview of JDK

JDK (Java Development Kik) Java development kit is the smallest environment for Java development. Its core is the JRE (Java Runtime Environment) Java runtime environment, which is the smallest environment for Java running. It contains Java system class libraries (Java packaged in advance) The functional classes of, developers can directly call, which greatly improves the efficiency of development) and the Java virtual machine (provides running tools for running and loading .class bytecode files), which have been updated to JDK14, and the most commonly used version is JDK8
[External link image transfer failed, the source site may have an anti-leech link mechanism, it is recommended to save the image and upload it directly (img-J4K3mbO6-1598799350303)(/img/bVbL6Ug)]

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-tx7N9mMz-1598799350306)(/img/bVbL6Uo)]

2.2 JDK download and installation

Download address http://www.oracle.com After the
download is complete, execute the next step until it is complete.
Note:
1. When installing multiple jdk at the same time, you need to use the specified environment variable to confirm which jdk is used.
2. The installation path should not have Chinese or special symbols such as spaces. It’s best to unify the catalog.
3. We also provide a green decompression version, which can be decompressed directly without installation.

2.3 Configuration of environment variables

JAVA_HOME
This configuration is to configure the jdk installation directory to specify which version of jdk to use.
Steps (Win7): Computer properties—>Advanced system settings—>Environment variables—>System variables—>New JAVA_HOME, enter the installation directory.

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-D3B0PZ7M-1598799350309)(/img/bVbL6VE)]

[External link image transfer failed, the source site may have an anti-leech link mechanism, it is recommended to save the image and upload it directly (img-JxOCNvh5-1598799350316)(/img/bVbL6VF)]

[External link image transfer failed, the source site may have an anti-leech link mechanism, it is recommended to save the image and upload it directly (img-DdDpzTWr-1598799350319)(/img/bVbL6VM)]

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-s5E3O1AJ-1598799350322)(/img/bVbL6VO)]

[External link image transfer failed. The origin site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-Ph5d80st-1598799350325)(/img/bVbL6VP)]

The PATH
system will look for executable files in the value of path configuration.
Need to add jdk\bin to the path.
Step: Environment variable—>Path—>%JAVA_HOME%\bin
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-Chc3fv1h-1598799350328)(/img/bVbL6V2)]

###### 2.4 Directory introduction [External link image transfer failed, the source site may have an anti-leech mechanism, it is recommended to save the image and upload it directly (img-e3izMj6x-1598799350331)(/img/bVbL6Wn)]

2.5 Commonly used packages of Java language (Supplement)

The Java language uses a package structure to organize and manage classes and interfaces. Commonly used packages are as follows:
2.5.1java.lang
This package provides basic classes developed in the Java language, such as Object, Class, Math...
2.5.2 java.util
contains a collection framework , Legacy collection classes, event models, date and time facilities, internationalization and various utility classes (string tag generator, random number generator and bit array, date Date class, stack Stack class, vector Vector class, etc.) . Various commonly used toolkits such as collection classes, time processing modes, date and time tools, etc.
2.5.3 java.io
This class provides a comprehensive IO interface. Including: file reading and writing, standard equipment output, etc.
2.5.4java.net
This package provides classes for implementing network applications and development.
2.5.5java.sql
This package provides APIs for accessing and processing data stored in the data source in Java language
2.5.6java.awt
Java window toolkit
2.5.7java.swing
provides classes for GUI design and development

3 Java language development software Eclipse

Official website https://www.eclipse.org/downloads/

3.1 Overview

Eclipse is an open source, Java-based extensible development platform. On its own, it is just a framework and a set of services for building a development environment through plug-in components.

3.2 Download and install

Go to the official website to download the complete file (Java EE enterprise level), unzip and install directly

3.3 Workspace of Java

The Java workspace is used to store all the Java development files and the storage location of the code. The workspace can be set by yourself
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-fC8vomra-1598917268678)(/img/bVbMchT)]

After creating the project, you can also view the workspace of the project on the project

3.4 A few things to know about Eclipse (extended)
3.4.1 How to restore accidentally deleted project files?

If you accidentally delete a file in the project and want to restore it, you can use the history function provided by Eclipse to
right-click the project—>Restore from Local Histoy—>select the project file to be restored—>Restore

[External link image transfer failed. The source site may have an anti-leech mechanism. It is recommended to save the image and upload it directly (img-Wfa0v84L-1598917268682)(/img/bVbMchX)]

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-tsFAn9td-1598917268687)(/img/bVbMchY)]

3.4.2 How to recover if the item column on the left is missing?

The project bar on the left will display all your project files, so it is very troublesome to lose it. You can choose the view of the window to restore it:
Windows—>Show view—>Project Explorer

[External link image transfer failed, the source site may have an anti-leech link mechanism, it is recommended to save the image and upload it directly (img-5dsDmOa6-1598917268693)(/img/bVbMch8)]

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-HyMrgIaF-1598917268698)(/img/bVbMcib)]

3.4.3 Commonly used shortcut keys

Ctrl+D: delete the current line

Ctrl+Alt+↓ Copy the current line to the next line (copy increases, some versions require Ctrl+win+Alt+↑)

Ctrl+Alt+↑ Copy the current line to the previous line (copy increases, some versions require Ctrl+win+Alt+↑)

Alt+↓ The interactive position of the current line and the next line (you can save the cutting and then pasting)

Alt+↑ The interactive position of the current line and the upper line (same as above)

Alt+← the previous edited page

Alt+→ the next edited page (of course for the above one)

Alt+Enter displays the properties of the currently selected resource (project, or file or file)

Alt+/ complete the currently entered code

4 Holle World case

4.1 Overview

For every programmer, the first project to be created when facing a new development environment is the Hello world project. The general creation process is:
create a Java project -> create a package -> create a class- >Edit content—>Click Run to output the result

4.2

First, create a project. The process of creating a project is equivalent to creating an environment and space suitable for running and storing class files.
Step 1: file—>java Project—finis

[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-bcmAqm07-1598917268700)(/img/bVbMciu)]

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-uRh5a1fP-1598917268702)(/img/bVbMciv)]

Step 2: Ctrl+N—>Search java Project—>next—>finish

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-kfHTNFke-1598917268704)(/img/bVbMciy)]

4.3 Create package

Note
1. The package name is lowercase
2. Usually the domain name is written in reverse
: src right click—>new—>package—>finish

[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-pKbo6nPE-1598917268706)(/img/bVbMciD)]

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-d5iS8eFI-1598917268709)(/img/bVbMciE)]

Shortcut method: Ctrl+N—>Search package—>finish

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-jbC2uT4u-1598917268711)(/img/bVbMciF)]

[External link image transfer failed, the source site may have a hotlink prevention mechanism, it is recommended to save the image and upload it directly (img-iESr6WV0-1598917268713)(/img/bVbMciE)]

4.4 Create Class

The method of creation is the same as the method of creating a package, the most important thing is to note

Note
1. The class name must strictly follow the camel case nomenclature (that is, if the class name is composed of multiple words, the first letter of the other combined words must be capitalized except for the first word).
2. You can also click the shortcut creation method on src, select class and create the package together.

[External link image transfer failed, the source site may have an anti-leech link mechanism, it is recommended to save the image and upload it directly (img-eeljAc0n-1598917268715)(/img/bVbMciI)]

package com.mtingcat.javabasis.holleworld;
/**
 * 现在是2020年8月31日,现在写到了Holle World即每一个程序员
 * 都要写的第一个项目,加油!!!!
 * @author MTing
 *
 */
public class holleWorld {

	public static void main(String[] args) {
		/*
		 *  public void println(String x) {
         *		synchronized (this) {
         *   		print(x);
         *  		newLine();
         *		}
    	 *	}
		 */
		System.out.println("Holle World!");//在控制台输出 Holle World!		

	}

}

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-14GUZlvw-1598917268717)(/img/bVbMci6)]

4.5 Description
//单行注释

/\* 多行注释 \*/

/\*

 \* 用来定义一个包

 \* package 加粗变红的效果,叫做关键字。专门用来定义包 。

 \* cn.tedu.hello 包名 \-- 全小写 + 公司的域名倒着写

 \* ; 是Java语句的结束符,相当于。

 \*/

package cn.tedu.hello;

/\*

 \* 用来定义一个类

 \* public 是关键字,专门用来修饰类的访问权限。公共的

 \* class 是关键字,专门用来定义一个类

 \* HelloWorld 类名 \-- 驼峰命名法

 \* { java代码 }

 \*/

public class HelloWorld {

 /\*

 \* 定义一个主函数/主方法/main方法

 \* public 是关键字,专门用来修饰main方法的访问权限。公共的

 \* static 是关键字,修饰main方法是静态方法

 \* void 空/无,main方法返回值是空

 \* main 方法名

 \* () 是方法的标志

 \* String\[\] args 方法的参数

 \* { Java代码/方法体 }

 \*/

 public static void main(String\[\] args) {

 /\*

 \* 用来向控制台输出指定的数据

 \* System 要发出系统指令

 \* out 发出一个输出的动作

 \* println 打印后换行

 \* () 是方法的标志

 \* "hello java" 方法的参数 \-- 要输出的数据

 \* ; Java语句的结束符

 \*/

 System.out.println("hello java");

 }

}
4.5 Project structure

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-EwuSxO4w-1598917268719)(/img/bVbMciz)]

[External link image transfer failed, the source site may have an anti-leech link mechanism, it is recommended to save the image and upload it directly (img-upHg3gR5-1598917268721)(/img/bVbMciA)]

4.6 Principle of execution

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-Gq0JFiSc-1598917268725)(/img/bVbMcjb)]

1. Compile: compile the java source file, which is the .java file, into a .class file through the javac command.
2. Execution: Start the java virtual machine first. Different operating systems have different JVMs, so java is cross-platform, and then load the HelloWorld.class bytecode file through JVM. And load the main method to execute the program.

Guess you like

Origin blog.csdn.net/weixin_43388956/article/details/108312671