Java software installation download JDK installation environment variable configuration text document run Java code 2023 version Eclipse installation

Table of contents

1. JDK installation and environment variable configuration

2. Text document runs Java code

3. Download and install Eclipse


1. JDK installation and environment variable configuration

1. To develop Java, you need to install JDK (JAVA Development Kit) first. The JDK download address is as follows: choose according to your own operating system.

https://www.oracle.com/java/technologies/downloads/

2. Install according to the steps

3. The environment needs to be configured after installation

(1) "My Computer" -> Right-click "Properties" -> " Advanced System Settings " or directly search for "Advanced System Settings" in the search box.

Open the image below and click "Environment Variables"

(2) Select "New" below

(3)

Variable name: JAVA_HOME

Variable value: your JDK installation directory , copy it and fill it in here

(4) Find " path " in the system variable and double-click to open it.

(5) Select "Edit Text",

Add " ;%JAVA_HOME%\binat the end of "Variable Value"

Remember to write the semicolon! !

4. Test whether the JDK is installed successfully.

Press win+R, enter cmd and press Enter to open the DOS window.

5. Enter java -version to check the Java version. If the version number appears, it means that the JDK is installed and configured correctly.

2. Text document runs Java code

1. Create a new text document and enter the code

public class Project1{
	public static void main(String[] args){
	System.out.println("Hello!");
}

}

2. Save as Project1.java (forced to change to java file) (beginners are recommended to save to the desktop for easy path switching later)

(Note: The naming here can be different from mine, but your file name must be the same as your class name)

(Example: If you are a public class Test{, you should write Test.java when renaming your text file)

3. Press win+R, enter cmd and press Enter, then switch to the path where .java is located

(My .java is saved to the desktop, so I enter the command cd Desktop )

4. Compile: Enter javac file name.java and press Enter. If there is no prompt, it means the compilation is successful.

5. Run: Enter the java file name (no suffix required)

You can see Hello! Already exported.

3. Download and install Eclipse

1. Official website address: Eclipse Downloads | The Eclipse Foundation

2. 

3. After entering, select " Select Another Mirror " to switch the mirror. I chose the one from Nanjing University in China. (I didn’t switch the mirror for the first time. I downloaded and installed it directly and got an error. Does anyone know why? The Korean version is not compatible?)

4. Then follow the prompts to install it. It is recommended to store it in a path other than C drive.

5. After the installation is complete, create a new project

6. Right-click the newly created Project and create a new class

7. It is recommended to check this box and the software will automatically add the main function for you.

8. Enter a piece of code to test. Hello! appears below, indicating success.

Note: If you create a new project and class, an error will be reported when running the code.

Just delete "module-info.java" on the left

You can also uncheck the check box to create this file when creating a project (what is the specific function of this file? If anyone knows, you can tell me in the comment area)

Guess you like

Origin blog.csdn.net/Chen298/article/details/132874647