1. Put the downloaded jdk1.8.0_161.tar.gz in the Ubuntu directory / usr / java directory
2. Unzip: Tar -ZXVF JDK1.8.0_161.tar.gz
3. Set an environment variable:
You can choose to modify the global profile, just apply the current user profile, just act on the current user, the former I choose, modify / etc / profile file, vi / etc / profile, add:
Export java_home = / usr / java / jdk1.8.0_161
Export jre_home = $ {java_home} / jre
Export classpath =.: $ {java_home} / lib: $ {jre_home} / lib
Export path =.: $ {java_home} / bin: $ PATH
4. Keep the modified configuration right away: Source / etc / profile
5. Check if the installation is successful: java -version