preface
This article introduces the basic installation and configuration of the JDK, and describes how to install it on different platforms (Windows, Linux, and MacOS). At the same time, the JDK version file used in this article can be seen at the end of the web disk link or through the official website link to choose their own download.
Windows
First unzip the jdk1.8.0_291.zip file into a folder: D:\\ Java:
You need to configure environment variables so that Java commands can be used globally. Software such as Tomcat relies on JAVA_HOME to locate Java. The following describes how to configure environment variables. First need to find system advanced Settings, there are two methods, you can choose Settings -> system -> about -> advanced system Settings (different Win10 versions will be different);
Or simply search to find the edit system environment variable:
After clicking any of the above methods, the following interface will appear:
Click on the environment variable here and then click New in the image that appears:
Then set the variable name JAVA_HOME to the JDK1.8 installation directory and click OK:
Then scroll down to the system variable named Path and click Edit:
Click New here and type %JAVA_HOME%\bin. When finished, click OK and close all the Windows that were just opened.
Then enter CMD with win+R:
Click OK and enter Java -version. If the version information is displayed normally, the installation is successful:
If the output version information is different from the installed version, JDK may have been installed and environment variables have been configured. You can run the where Java command to check the location of Java. If the command output is not the installation location, JDK has been installed and environment variables have been configured. You need to find the environment variable configuration just opened to modify.
Linux
So let’s assume here that you haveJDK1.8
The zip package has been uploadedlinux
On the mainframe. I’ll put it here/home/butterfly/develop
Directory, first throughtar -zxvf jdk-8u291-linux-x64.tar.gz
Decompress it and pass itls
You can see that the decompression is successful:
Then we also need to configure environment variables so that we can use Java commands globally. Here are three methods:
-
This applies only to the current shell
By entering the export PATH = $PATH: / home/butterfly/develop/jdk1.8.0 _291 / bin configuration can be successful, The/home/butterfly/develop/jdk1.8.0 _291 / bin modification for your JDK installation directory, and then through the Java – version command can be found that already can normal use the Java command:
Note, however, that this configuration will be invalidated the next time you turn the current shell off, so here are two permanent configurations. In Windows, we configured the JAVA_HOME environment variable first, and then we configured the PATH. In Linux, we configured the full PATH. Only need to execute the export JAVA_HOME = / home/butterfly/develop/jdk1.8.0 _291, and then execute the export PATH = $PATH: $JAVA_HOME/bin can achieve the same effect.
-
This parameter takes effect permanently for the current login user
Bashrc: vim ~/. Bashrc: vim ~/. Bashrc: vim ~/.
Export JAVA_HOME = / home/butterfly/develop/jdk1.8.0 _291 export PATH = $PATH: $JAVA_HOME/binCopy the code
Bashrc (source ~/.bashrc) is the source ~/.bashrc (source ~/.bashrc) command. If you close the shell and open it again, you can still run the Java command. Finally, only root can use the Java command:
-
It is valid permanently for all users
You can run the vim /etc/profile command to open a profile file. You also need to add the following configuration to the end of the file:
Export JAVA_HOME = / home/butterfly/develop/jdk1.8.0 _291 export PATH = $PATH: $JAVA_HOME/binCopy the code
Then save and run the source /etc/profile command to see that Java commands are now available to all logins.
MacOS
Install in MacOS directly through the form of DMG file, after the installation guide click, the following interface will finally appear, that is, the installation is successful.
Here you can see that the shell is ready to use Java commands:
To configure the JAVA_HOME environment variable, run /usr/libexec/java_HOME Can see similar/Library/Java/JavaVirtualMachines jdk1.8.0 _291. JDK/Contents/Home output, this is MacOS automatically assign us a Java installation directory. Then enter vim ~/.bash_profile and append the following configuration to the file:
Export JAVA_HOME = / Library/Java/JavaVirtualMachines jdk1.8.0 _291. JDK/Contents/HomeCopy the code
Save the configuration and exit. Run the source ~/. Bash_profile command and enter $JAVA_HOME/bin/ Java -version. If you can also enter the Java version, the JAVA_HOME configuration is successful.
Links to resources
Link: pan.baidu.com/s/1P3qHk9dX… Extraction code: YIM8
Download address: www.oracle.com/java/techno…
conclusion
The above is the basic installation of JDK on different platforms and the configuration of related environment variables, if there is any error, please leave a comment.