Install the JDK environment in the Ubuntu branch Linux operating system and the ubuntu branch linuxjdk
In the Linuxer system, the jdk environment is often required. The following describes the official JDK Installation Method of Oracle.
Step 1: Go to the jdk official website to download the JDK installation file of the corresponding version.
Step 2: Decompress the file and modify the file name
$ sudo mkdir /usr/lib/jvm$ sudo tar zxvf jdk-8u45-linux-x64.tar.gz -C /usr/lib/jvm$ cd /usr/lib/jvm$ sudo mv jdk1.8.0_45 jdk
Step 3: Configure environment variables:
sudo gedit /etc/profile
Add the following code:
export JAVA_HOME=/usr/lib/jvm/jdk export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
Why not modify "~ /. Bashrc file and modify "/etc/profile? These files have different functions.
/Etc/profile: This file sets the environment information for each user in the system. This file is executed when the user logs on for the first time. And collect shell settings from the configuration file in the/etc/profile. d directory.
/Etc/bashrc: execute this file for every user running bash shell. When bash shell is opened, the file is read.
~ /. Bash_profile: each user can use this file to input the shell information dedicated to their own use. When a user logs on, the file is executed only once! By default, it sets some environment variables to execute the user's. bashrc file.
~ /. Bashrc: The file contains bash information dedicated to your bash shell. The file is read when you log on and every time you open a new shell.
~ /. Bash_logout: execute this file every time you exit the system (exit bash shell. In addition, the variables (global) set in/etc/profile can act on any user ~ The variables (local) set in/. bashrc can only inherit the variables in/etc/profile. They are "Parent-Child" relationships.
We can see that "~ The environment variables of/. bashrc are only useful for shell, while "/etc/profile" can be used for any program of any user.
Step 4: Make the configuration take effect:
source /etc/profile
Step 5: verify whether the verification takes effect:
java -version