

# sudo update-alternatives -set java /usr/lib/jvm/jdk1.8.0_151/bin/java # sudo update-alternatives -install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_151/bin/javac" 0 # sudo update-alternatives -install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_151/bin/java" 0 Use update-alternatives to inform Ubuntu about the installed java paths. Step 4: Inform Ubuntu about the installed location The environment file should now be similar to this text: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin" Add the below variables at the end of environment file, making changes for your specific version and update.

HOME directory paths can be different based on version and update,here the version is 1.8 and the update is 151. Update the existing PATH variable by adding the below bin folders, separated with a colon. # sudo tar -xvzf ~/Downloads/jdk-8u151-linux-圆4.tar.gzĮdit the environment file. # cd /usr/lib/jvmĮxtract the downloaded JDK. Step 2: Extract JDK to Java's default locationĬreate a jvm folder in /usr/lib/ which is the default location for Java. It is recommended that you install only the latest JDK.
