JDK installation

1. Install JDK


JDK directory

bin directory contains tools for Java development

db directory comes with the database

include header files

jre The JRE that comes with the JDK, it is the same as the public JRE

lib The library files required by the development tools

src.zip Java source code

2. Configure the path environment variable

After installing the JDK, you need to switch to the bin directory in the JDK to use these commands

 

When you enter a command in the command window, the system will first check whether the command exists in the current directory; if it does not exist, it will look for the command in the path configured by the path environment variable.

 

Configure the path environment variable. After the setting is complete, you need to reopen the command window to take effect.

 

Check if the setting is successful

 


3. Write the code in Notepad and save it as Hello.java

Create a new HelloWorld.java source file in a directory

Note that the file extension must be *.java

3.2 Writing source code

Note: java is strictly case sensitive

class  HelloWorld{

public static void main(String[]args){

System.out.println("Hello World!");

}

}

 


4. Compile


5. Run


6. Instructions for the program

1) A Java program must be written in a class, a class is the basic unit of a Java program

2) Use the class keyword to define a class

3) The class is followed by the class name, the class name is the name given by the programmer, and the first letter of each word is capitalized

4) The content of the class must be enclosed in a pair of curly brackets

5) For the program to run, there must be a main method, and the writing method of the main method is fixed

6) public indicates that it is public

7) static means it is static

8) void indicates that the main method has no return value

9) main is the method name. When the JVM runs the program, it will start from the main method, and when the main method is executed, the program ends.

10) A pair of parentheses after main is a method parameter, which is an array

11) String is a class defined by SUN, representing the string type

12) System.out.println(); This is a statement, ending with a semicolon, the function of this statement is to print the content on the screen

13) "Hello World!" enclosed in double quotes is a string

14) System is a class defined by SUN, and System.out can be understood as the standard output device of the system, that is, the display;

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325462726&siteId=291194637