So you don't think the Post is long and complicated, start this Post by end, In short the commands needed to install or update Java. If you have questions and want more details, Please read the entire Post. Are only 4 Steps!
# TIP: Verifique a versão do Java antes e depois da instalação/atualização com o comando "java -version" via Terminal (CTRL + ALT + T). 1. On Ubuntu, Open the Terminal (CTRL + ALT + T) and create the installation directory the Java (If there is no) sudo mkdir /opt/Java 2. Remove the old installation (If there is): sudo rm -r /opt/Java/JRE 3. Download +new Java http version://www.java.com/pt_BR/download/manual.jsp#lin (choose Linux x 64) 4. Run the command to install or update Java sudo mv ~/Downloads/JRE-8u101-Linux-x 64.tar.gz /opt/Java && CD /opt/Java && sudo tar -xvf jre-8u101-Linux-x 64.tar.gz && sudo mv ./jre1* ./JRE && sudo rm -(f) ./JRE-*.tar.gz ATTENTION: ~/Downloads/ is the directory where you downloaded the new Java. JRE-8u101-Linux-x 64.tar.gz is the name the new Java file you downloaded (REPLACE 2 x!!!) /opt/Java is the directory where we will install Java
It's just that, I use and it works!
Time or another Java suffers an update, then we always have the disadvantage of performing that piece of commands. If you want this done easily, look on the Internet how to add third-party repositories and install Java via apt-get. This is not the purpose of this Post.
In this Post we will see a safe! The idea is to make everything from conventional mode, IE, Enter the java.com Web site and follow the installation process. But I assure you it doesn't hurt, always use this method and so I decided to register here.
Before you begin, leave it very clear that the procedures were done in an environment using Ubuntu Linux and Firefox browser. Let's consider, still, Java being installed / updated in the directory /opt/java/jre. If this directory does not exist, don't worry, We will create it after.
It is interesting you also check the Java version before and after installation / Update. You can do this in two ways:
1. Check the version of Java through the Terminal | To check your current version of Java, open terminal (CTRL + ALT + T) and type:
2. Check the version of Java by the browser | To check your current version of Java, visit the site http://java.com/verify or open the Firefox browser and type in the address bar:
Create the Java installation directory, If there is no. On Ubuntu, Open the Terminal (CTRL + ALT + T) and create the directory /opt/java Java installation, but only if it does not exist, of course!
sudo mkdir /opt/Java
Remove the old Java, If there is. In The Terminal (CTRL + ALT + T), Enter the command below to remove the old installation of Java (If there is).
sudo rm -r /opt/Java/JRE
Download + new Java version. Visit http://www.java.com/pt_BR/download/manual.jsp#lin, Select Linux x 64 and download. The file is something like “jre-8u101-linux-x64.tar.gz“.
Run the command to install / Update Java. Whereas the file you downloaded is in the Download (/home/user/Download), copy and paste the command below in Terminal, replacing “jre-8u101-linux-x64.tar.gz” by the correct name of the file you just downloaded (Note that it appears twice in the command).
sudo mv ~/Downloads/JRE-8u101-Linux-x 64.tar.gz /opt/Java && CD /opt/Java && sudo tar -xvf jre-8u101-Linux-x 64.tar.gz && sudo mv ./jre1* ./JRE && sudo rm -(f) ./JRE-*.tar.gz
On the above command, Note that:
~/Downloads/ is the directory where you downloaded the new Java.
jre-8u101-linux-x64.tar.gz is the name of your new Java file (replace!)
/opt/java is the directory where we will install Java
Basically doing this everything will be working! Test in the Terminal and on the Browser version of Java as Step 1.
First installation of Java
If it is the first installation of JAVA, copy and paste the command below in Terminal, adjusting the correct installation path if necessary:
sudo update-alternatives --install /usr/bin/Java java /opt/Java/JRE/bin/Java 10 && sudo update-alternatives --set java /opt/Java/JRE/bin/Java
Updating the Firefox plugin
When testing in the Terminal with Java-version (see step 1), Note that the updated version is already running. But, is it possible to test in Firefox browser, checking in http://java.com/verify, that even included the old version. To solve this, then use the following command to update the link to the plugin Firefox
CD /usr/lib/Firefox-addons/plugins/ && sudo ln -with /opt/Java/JRE/lib/AMD64/libnpjp2.so