2.1.2 Setting up JDK

After downloading the JDK, you need to install the development package and specify where to install it, and you will need this information later.

  • On Windows, start the installer. You will be asked where you want to install the JDK. It is best not to accept the default location that contains spaces in the path name, such as c:\Program Files\Java\jdkl6. Just take out the Program Files part of the path name.
  • On a Mac, run the installer. This will install the software to /Libraiy/Java/JavaVirtualMachines/jdk1.8.0_version.jdk/Contents/Home. Use Finder to find this directory.
  • On Linux, just unzip the .tar.gz file to a location of your choice, such as your home directory, or /opt. If installing from the RPM file, you must repeatedly check whether it is installed in /usr/java/jdk1.8.0_version.

When installing the JDK on Windows or Linux, you need to complete another step: add the jdk/bin directory to the execution path-the execution path is the list of directories that the operating system traverses when searching for executable files.

  • On Linux, you need to add this line at the end of the ~/.bashrc or ~/.bash_profile file:
    export PATH=jdk/bin:$PATH

  • On Windows, start the "Control Panel", select "System and Security", then select "System", select "Advanced System Settings". In the "System Properties" dialog box, click the "Advanced" tab, and then click the "Environment Variables" button. (See the picture below)

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

Scroll through the "System Variables" list until you find the variable named Path. Click the "Edit" button. Then click the "New" button to add the jdk\bin directory to the environment variable, my name is C:\java\jdk16\bin. Finally, click the "OK" button to complete the setting. (See the picture below)

Insert picture description here

Insert picture description here

Save the settings made. All newly opened console windows will have the correct path.
You can test whether the settings are correct as follows: open a terminal window, key person:
javac -version
then press Enter. You should see the following information displayed:

Insert picture description here

If you get something like "javac: command not found" or "The name specified is not recognized as an internal or external command, operable program or batch file" (the specified name is not an internal or external command, you can The executed program or batch file), you need to return it to double check your installation.

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_33790600/article/details/114992489