Configuration of Java environment variables under Ubuntu
Reprinted from and modified from: https://jingyan.baidu.com/article/c33e3f48a3365dea15cbb5c9.html l
1. Download JDK on Oracle's official website: I downloaded jdk-8u131-linux-i586.tar.gz
2. Create the Java folder
usr/lib/jvm Jdk folder after decompression will be placed in this directory
Use the command in the terminal: sudo mkdir /usr/lib/jvm
3. decompress
First copy the downloaded tar.gz file to home/, then decompress home/jdk-8u131-linux-i586.tar.gz to usr/lib/jvm
Use the command: sudo tar -C /usr/lib/jvm -xzf xx.tar.gz
You can see if the decompression process is ok
4. Check if there is java optional on this machine
Use the command: sudo update-alternatives --list java
Normal display No java optional
5. Configure environment variables
Use the command: sudo gedit ~/.bashrc
Add at the end of the opened file:
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_131 (path to the unzipped jdk folder)
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Except for the first variable that needs to be modified, all others can be copied.
6. make the configuration take effect
Use the command: source ~/.bashrc
7. Verify that the environment variables are configured successfully
rsion
There is jdk version information, indicating that the configuration is successful!