In Linuxer systems, the JDK environment is often required, and the following describes the Oracle official JDK installation method
First step: Download the corresponding version of the JDK installation file to the JDK website
Step two: Unzip the file, modify the filename
sudo mkdir /usr/lib/sudotar zxvf jdk-8u45-linux-x64.tar.gz -c/usr/lib/ /usr/lib/sudomv jdk1. 8. 0_45 JDK
Step Three: 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 the "~/.BASHRC" file and modify "/etc/profile" here? These files have some different effects
/etc/profile: This file sets the environment information for each user of the system, and the file is executed when the user logs on for the first time. and collect the shell settings from the configuration file of the/ETC/PROFILE.D directory.
/ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
~/.bash_profile: Each user can use this file to enter shell information dedicated to their own use, and when the user logs in, the file is only executed once! By default, he sets some environment variables to execute the user's. bashrc file.
~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.
~/.bash_logout: Executes the file each time it exits the system (exiting the bash shell). In addition, the variables set in/etc/profile (global) can be applied to any user, while the variables set in ~/.BASHRC, etc. (local) only inherit variables from/etc/profile, they are "parent-child" relationships.
It can be concluded that the "~/.BASHRC" environment variable is useful only to the shell, while "/etc/profile" is available to any user of any program
Fourth step: Make the configuration effective:
Source/etc/profile
Fifth step: Verify that it is in effect:
Java-version
Ubuntu Branch Linux operating system installation JDK environment