Advertisement
Umarkov45

How to install Java JDK 8 on Linux

Oct 26th, 2021 (edited)
911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.81 KB | None | 0 0
  1. ### Sign as root ###
  2. su
  3.  
  4. ### Before you start with the setting up Java, you will need to remove the OpenJDK/JRE from the system ###
  5. apt-get purge openjdk-\*
  6.  
  7. ### Check whether Ubuntu OS architecture is 32-bit or 64-bit ###
  8. neofetch
  9.  
  10. ### Download the Java JDK and extract it somewhere ###
  11. Link: https://archive.org/details/jdk-8u301-linux-umarkovwebsite
  12.  
  13. ### Create "java" folder in the root directory ###
  14. Create a folder (sign in as root first!) named "java" in the root dir and set the permission to 755 or 777.
  15.  
  16. ### Set the permission of that "java" folder ###
  17. To do this: "sudo chmod -R (755 or 777) /java"
  18.  
  19. ### Make sure you create directory as described below ###
  20. It will look like this: "/java/(PUT YOUR JDK FOLDER VERSION HERE)/"
  21. Example: "/java/jdk1.8.0_301"
  22.  
  23. ### Add the following system variables to the end of /etc/profile file ###
  24. ### To do so: "nano /etc/profile" ###
  25. JAVA_HOME=/java/jdk1.8.0_301
  26. PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
  27. export JAVA_HOME
  28. export PATH
  29.  
  30. ### Save it (ctrl+s) and exit (ctrl+x) ###
  31.  
  32. ### Now reload the enviorment ###
  33. . /etc/profile
  34.  
  35. ### Its time to let Ubuntu know where our JDK/JRE is located ###
  36. ### Copy-paste below lines into a command prompt ###
  37. update-alternatives --install "/usr/bin/java" "java" "/java/jdk1.8.0_301/bin/java" 1
  38. update-alternatives --install "/usr/bin/javac" "javac" "/java/jdk1.8.0_301/bin/javac" 1
  39. update-alternatives --install "/usr/bin/javaws" "javaws" "/java/jdk1.8.0_301/bin/javaws" 1
  40.  
  41. ### Tell Ubuntu that our installation i.e., jdk1.8.0_05 must be the default Java ###
  42. update-alternatives --set java /java/jdk1.8.0_301/bin/java
  43. update-alternatives --set javac /java/jdk1.8.0_301/bin/javac
  44. update-alternatives --set javaws /java/jdk1.8.0_301/bin/javaws
  45.  
  46. ### Test the installation using below command ###
  47. java -version
  48.  
  49. ### DONE!! ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement