This is the first day of my participation in Gwen Challenge

Java is a special high-level language. It has both the characteristics of a compiled language and the characteristics of an interpreted language.

Download the Java JDK

First, you need to understand three terms: JDK, JRE, JVM.

The relationship between them is shown belowGenerally speaking, if you only want to run Java programs, you only need to install JRE. Download is easy, you just need to go to the Oracle official website to download, xiaobian here to give you the link, you can also go to the official website to download.

JDK Download link

You can find the version of your computer.

After downloading, double-click to open the installation.

Here you must remember the installation path, later configuration environment will be used.

Set the PATH environment variable

Why set environment variables

First we need to know why we set the PATH environment variable. We have downloaded and installed the JDK, but can't we run Java programs? Yes, we have the JDK installed, but the Windows operating system looks for commands based on the PATH PATH, and if it can be found it means the command is executable. Linux also searches for commands based on PATH. However, the Linux operating system is case-sensitive and PATH is different from PATH. Therefore, you only need to set the PATH variable in both Windows and Linux operating systems.Copy the code

How do I set environment variables

Right - click the computer icon on your desktop, find the properties, and click Open.Copy the code

Find advanced System Settings on the right and click Open.

Locate Environment Variables in the Advanced option and click open.

Find path in the user variable. If not, create a new one and edit it.

/* Why not use system variables, what's the difference? In fact, the system variable and the user variable is not much different, but the system variable is for all users, and the user variable is only for the use of the user, in their own computer we can use the user variable, but in the computer room we may need to use the system variable. (Don't ask me how I know, ask for details!) * /Copy the code

When editing, you need to copy your own JDK installation path, click new, paste your own path to it.

/* Remember not to click ×, be sure to click until exit. * /Copy the code

After setting, you can press the shortcut key Win +R, enter CMD, open the command window, and enter javac and Java to check whether the setting is successful.

The following two images show that you have configured your environment, so let’s start writing our first Java program!

The first Java program, HelloWorld

One of the simplest Java programming tools is Notepad. Create a new notepad and write graph statements in it. (Don’t understand, learn later)

I’m going to save it as Hello. Java, and I’m going to keep in mind that it’s a good idea to create a folder for your Java code. (The name must be the same as the name of the public class.)Next win+R enter CMD to enter the command window CD folder // This command is used to enter the folder.

As mentioned earlier, Java is a semi-compiled and semi-interpreted language, so you need to use Javac to compile the source file first to get the class file, as shown in the following figure

If there is an error, there will be an error message, as shown above. When you open your Java file folder, you will magically find that it has an extra class file.

Yeah, that’s what you just compiled. Next we type Java and run it

Hello World appears. Our first Java program is done here, have you learned it?

/* This article is for beginners. Feel free to leave a comment. * /Copy the code