030_ Construction of java development environment

Time:2021-6-13

Construction of java development environment

JDK download and installation

Jdk8 Download

  1. Baidu search jdk8

image.png

  1. Choose windows x64 to download

image.png
image.png
image.png

JDK uninstall

  1. Viewing Java in environment variables_ Home configuration is the JDK installation path.
  2. Remove the JDK installation directory.
  3. Delete environment variable Java_ Home, delete Java in path_ Home related configuration.
  4. Enter Java – version on the command line to verify whether the uninstall is successful.

image.png

JDK installation

  1. Double click JDK to install it.


image.png

  1. Install JDK: select the development tool, change the installation path, and select the next step.

image.png

  1. Install JRE: change the installation path and choose next.

image.png

  1. Successfully installed, click close.

image.png

Configure environment variables

  1. Open environment variables: my computer – right click – properties – advanced system settings – environment variables.

image.png

  1. Configure Java_ Home: system variable new new system variable Java_ HOME。

image.png

  1. Configure path: double click the end of path – to add (;%) JAVA_ HOME%\bin;% JAVA_ HOME%\jre\bin;)。

%%Represents the reference variable,% Java_ Home% refers to Java_ The home variable.
; Represents the value of the split variable. Windows uses (;), Linux uses (:).

image.png
image.png

  1. Input Java – version from the command line to verify whether the environment variables are installed successfully and configured correctly.

image.png

JDK directory introduction

  1. Bin: executable program, including Java, javac, Javadoc, jar, etc.
  2. Include: C language header file.
  3. JRE: Java runtime environment.
  4. Lib: Java class library.
  5. Src. Zip: java basic class source code.

image.png

HelloWorld and simple grammar rules

Write, compile and run hello. Java

  1. Create a new hello. Java file.

image.png

  1. Write the code.
public class Hello {
	public static void main(String[] args) {
		System.out.print("Hello,World!");
	}
}
  1. Compile code: enter the directory of Hello. Java – “javac hello. Java -” from the command line to generate the hello. Class file.

Javac compiler command, javac hello. Java, compiles the hello. Java source file into the hello. Class bytecode file.

javac Hello.java

image.png

  1. Run code: Java Hello – run hello. Class file – output Hello, world!.

Java explain command, Java Hello, the Java virtual machine interprets and runs the hello. Class bytecode file.
Java command, bytecode file can’t take. Class.

java Hello

image.png

Common mistakes

  1. The file name is inconsistent with the class name. The java file name must be consistent with the class name and capitalized.
  2. Word case problem, Java is case sensitive.
  3. The symbols are in Chinese, and the Java symbols must be in English.
  4. Try not to use Chinese in the code, which may lead to program errors due to coding problems.

Compiled and interpreted

Installation and use of Notepad + +