Installing JDK: [Manually using .tar.gz]
1. Go to Oracle JDK
2. Select “JDK Download”
3. “Accept the license terms” and download .tar.gz file based on your OS type
- Linux X86 (32 bit)
- Linux X64 (64 bit)
4. After you download the file, right-click the file and select “Extract here”
5. You will find a folder with the name similar to “jdk_1.8_version”
6. Open the terminal (ctrl+alt+t)
7. sudo mv /path/to/your/jdk_folder/ /usr/lib/jvm
8. The complete folder “jdk_1.8_version” will be moved to /usr/lib/jvm
9. Now we need to inform Ubuntu to use this JDK.
10. sudo gedit /etc/profile.d/oracle_jdk8.sh
11. Gedit would open a blank file for you. Write the following code in the file.
export J2SDKDIR=/usr/lib/jvm/oracle_jdk8
export J2REDIR=/usr/lib/jvm/oracle_jdk8/jre
export PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin
export JAVA_HOME=/usr/lib/jvm/oracle_jdk8
export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db
12. Save the file. Close it.
13. Once you restart the changes will be made.
14. To force the changes to happen in the current session, without restarting, execute the following:
source /etc/profile.d/oraclejdk.sh
15. Now, your ubuntu can use JDK 8! Happy Javaing!