Java acquaintance (b) - (build Java environment, and the first Java program, attached JDK completely uninstall tutorial)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_44222492/article/details/99333076

table of Contents

First, build a Java environment
1. JDK download
2. JDK installation
3. Set Environment Variables
Second, the first Java program
1. output on the console "Hello World!"
2. Java cross-platform principle
3. Note the code and coding conventions
Three, JDK completely uninstall tutorials
1. The first step, uninstall or remove JDK
2. Second, remove registry
3. The third step, delete the environment variable
···

First, build a Java environment

1. JDK download

JDK (Java Development Kit): Java Development Kit
JRE (Java Runtime Environment): Java runtime environment
of Java JDK, also known as Java SE (formerly J2SE), Download: https://www.oracle.com/technetwork/java /javase/downloads/index.html.

Here JDK download process, the following steps:

Oracle released Java 11, 2018 which is the second major version of Java. This version also since Java 8, the first long-term support (LTS) version, which means that Oracle will be at least until 2026 to provide security updates and bug fixes. So you can rest assured that select this version!

(1) Open your browser and enter the URL https://www.oracle.com/technetwork/java/javase/downloads/index.html, enter the JDK download page, select the JDK version in the download page, click JDK behind the [DOWNLOAD] button.

Click on the download button

(2) entering a new page, you need to select the consent agreement] [Accept License Agreement radio button

start download

(3) Due to the latest version of JDK11 (JDK 11.0.4) with the latest version of JDK8 (JDK 8u221) requires companies to pay to use the account, so companies need to log in to download click to download the account before the operation, if there is no business account, download the JDK only to learn, then the next step.
(4) in the previous step you can download the latest version of the JDK [JDK 12.0.2]. If the speed is too slow to provide here -> JDK12 (the JDK 12.0.2) Direct download link .

Password: qcat
Accept Agreement
Download completed

(5) To download the free JDK11, JDK10 or JDK8, offers a free download link here (both 64-bit installer window system)

2. JDK installation

(1) Double-click the downloaded installation file (for example to JDK11), will welcome dialog box pops up, click Next button.

Welcome Dialog

(2) In the dialog box, you can select the components installed, select the default settings here, such as Java to change the installation path, click [change], change the location you want to install, click the OK button, will return to the custom installation dialog box, click Next.

Custom Installation
Change the path

(3) to start the installation JDK, automatically installed. (If JDK8, JRE directory will pop up a file dialog box, you can click on the Next button).

start installation

(4) the installation is complete, click [Close] button.

The installation is complete

3. Set Environment Variables

Objective Configuration Environment variables: the user can be used anywhere in the command window command
path: the path for a specific operating system executable instructions
classpath: specify classpath by running a Java Virtual Machine in order to catalog a class Find this class

  [Computer] -> [Property] -> [Advanced System Settings] -> [Advanced] -> [Environment Variables]

(1) on [computer] icon right-click on the shortcut menu, select [Property] command to bring up the Properties dialog box, click on its left side [Advanced System Settings], will open the System Properties dialog box, single click the environment variables button [], the environment variables dialog box pops up.

Click Properties
Advanced System Settings

(2) In the Environment Variables dialog box, click [New] under [System Variables] bar button to create a new system variable. Enter the New System Variable dialog box, respectively, the variable name JAVA_HOMEand variable value (ie, JDK installation path), click the button].

Configuration environment variable

(3) Double-click the Path variable in the Environment Variables dialog box, modify, add in the original variable value %JAVA_HOME%\bin(if JDK8, you need to add %JAVA_HOME%\jre\bin), click OK to complete the setting environment variables.

Edit Path

(4) JDK installation must be confirmed after a successful environment variable is correct. Press [Windows + R] keyboard shortcut to open the Run panel, enter cmd into the console. [Java] and [Enter] command Javac respectively in the console, press [Enter], if will display the corresponding information, the JDK environment to build success.

Run cmd
java
javac

(5) can be used Java -versionto check the JDK version

Check the version

Second, the first Java program

1. output "Hello World!" Message on the console programming steps:

(1) Press the Windows key to open the operation panel + R, [enter] notepad Notepad open, enter the following code in Notepad:
public class HelloWorld{
	public static void main(String[] args){
		System.out.println("Hello World!");
	}
}
(2) Select File] -> [Save] command, select the storage location for the desktop, the use of quotation marks when entering no name ( "") encloses the file name, such as "HellWorld.java"

Storage
Storage

(3) Java source code needs to be compiled into byte code to be recognized JVM, the JDK javac.exe required command. Assume Helloworld.java file is saved on the desktop (C: \ Users \ Administrator \ Desktop), press the Windows key + R to open the Run panel, enter [cmd], click [OK] button to start the console, enter the following command in the console :

Attached: ······> (Win10 right-click Add Open Command Window Here [])

cd C:\Users\Administrator\Desktop
javac HelloWorld.java

To compile the source code, the source code is compiled, it will generate the corresponding class files at the same position, which is a Java byte code compiled files.

(4) input in the console Java HelloWorldcommand execution Helloworld.class compiled byte code file.

result

Note: Use Javac xx.java command to compile Java source code, if no error message pops up, indicating successful compilation, might prompt some of the warning, but the compiler can pass through; but if Exception exception error message appears tired, then source code in question can not complete the compilation process, which can determine the cause of the error and abnormal position according to the code Exception, resolve code errors.

2. Java cross-platform principle

Programs written in JAVA
The principle of cross-platform Java

3. Note the code and coding conventions

3.1 Code Comments
(1) a single line comment

  " " //A single line comment markers from the symbol " //" begin to know all the content changing behavior only as comments are being ignored by the compiler.
The syntax is as follows:

//注释内容
(2) multi-line comments

  " " /**/Multi-line comments mark, the symbol " /*" and " */everything between" are footnotes. Content annotation can wrap.
The syntax is as follows:

/*
注释内容1
注释内容2
···
*/
note:

(1) in a multi-line comments may be nested in a single line comment. E.g:

/*
	程序名称:HelloWorld //开发时间:2019/8
*/

(2) In the multi-line comment multi-line comments can not be nested, the following code illegal:

/*
	程序名称:HelloWorld
	/*
		开发时间:2019/8
		作者:lrk
	*/
*/
(3) Documentation Comments

  " /** */" Mark documentation comment. The symbol "/ *" and content between the "* /" are comments document content. When the document annotation appears in the declaration (declaration such as class, declare member variables of the class, tired of the members of the method declaration, etc.) before that will be read as document content javadoc javadoc documentation tool. The same format and multi-line comments in the document annotation.
javadoc

Three, JDK completely uninstall tutorials

1. The first step, uninstall or remove JDK;

  There are three ways ::

(1) Control panel for unloading

Control Panel to uninstall

(2) security software (such as 360) comes with a function to uninstall software uninstall tool

360 Uninstall

(3) delete jDK folder (my JDK installation directory is: C: \ Program Files \ Java)

2. The second step, delete the registry;

(1) Press the Windows key + R to open the Run panel, enter [regedit] Open the Registry Editor

Open the Registry Editor

(2)找到HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft

Find JavaSoft

(3) Delete all JavaSoft folder and its subdirectories.

Remove the registry

3. The third step, delete the environment variable;

  [Computer] -> [Property] -> [Advanced System Settings] -> [Advanced] -> [Environment Variables]

(1) Delete JAVA_HOME variable
(2) delete CLASSPATH variable
(3) Edit Path variable

  Delete inside %JAVA_HOME%\bin;and %JAVA_HOME%\jre\bin;(delete only two), in JDK11 above and due to no longer comes with jre, so just delete %JAVA_HOME%\bincan be.

4. The fourth step, the C disk Windows \ java.exe System32 and Windows \ SysWOW64 folder, javaw.exe and javaws.exe files deleted.

(The default installation jdk8 copy these three files to these directories)

The final step, type java command line, it is checked whether the unload is completed;

Uninstall complete

Guess you like

Origin blog.csdn.net/weixin_44222492/article/details/99333076