How to install JDK in Ubuntu and JDK in Ubuntu
Download JDK
1. Download the related JDK from the Oracle official website.
2. Create a folder under your account and name it "Java". Of course, you can name the folder at will.
That is, in/home/user/Java, my location is/home/nomasp/Java. Then extract the downloaded file and copy it here.
3. Open the terminal. If the terminal cannot be found, search for it.
Configure Environment Variables
Tips: use Ctrl + H to show hidden files.
1. Enter:
sudo emacs /etc/environment
This command uses emacs to open the environment file in the etc folder. (Root is required for some content in this tutorial. Please refer to the following link: Get root permission on Ubuntu (Linux ).
In addition to emacs, you can also use the built-in gedit.
sudo gedit /etc/environment
2. Add the following content to the environment file:
export JAVA_HOME=/home/user/Java/jdk1.8.0_60 export JRE_HOME=/home/user/Java/jdk1.8.0_60/jre export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
Here, user is your account name. For example, if I enter nomasp here and jdk1.8.0 _ 60 is the JDK version number, the download may be different.
3. Continue to modify the file and enter:
sudo emacs /etc/profile
The content of this file is too large. After three f1 instances, fill in the blank space before the word ummask:
export JAVA_HOME=/home/user/Java/jdk1.8.0_60 export JRE_HOME=/home/user/Java/jdk1.8.0_60/jre export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$JAVA_HOME/bin
4. Save the preceding changes and log out.
5. Test JDK. Enter the following in the terminal:
jdk -version
If "java version" 1.8.0 _ 60 "is displayed, JDK is successfully installed.
Copyright Disclaimer: This article is an original article by NoMasp ke yuwang. If you need to reprint it, please contact me.