Italiano
Install Java on Linux
In this brief guide, we will see how to install the Oracle’s Java Virtual Machine (JVM) plus the plug-in for the browser on Linux. The following steps have been tested with Ubuntu but should work with other distributions. First to begin with the installation it is good to remember that the guide explains how to install Java 7 Update 25 through archive; but since Java is frequently updated remember to replace the version according to which one you have downloaded, it could be for example Java 7 Update 30 or Java 8, in every case pay attention to the archive’s name that is in the form "jre-7u25-linux-i586", where…
  • jre, stands for Java Runtime Environment;
  • 7u25, it is the JVM version;
  • linux, Linux JVM;
  • i586, 32 bit JVM.
Therefore, for Java 8 32-bit the archive’s name might be something like "jre-8-linux-i586", while the folder to extract could be something like "jre1.8.0". Remember, if the JVM version is different you must change the commands that use the folder whose name depends on the JVM version. Let’s begin the installation.

JVM installation

First you must download the archive paying attention for the Operating System you are on. Is it 32 or 64 bit? Do not download file marked whit "RPM" but simple binary file with "tar.gz" extension.

Once the download is complete, you must extract the content of the archive in a folder, you can use the interface by opening it with double click, or you can run the command below. You must extract the entire folder, for example "jre1.7.0_25". Remember that you must move with the cd command in the directory where the archive is located.

tar -xvf jre-7u25-linux-i586.tar.gz

Now that the folder "jre1.7.0_25" is extracted on the Hard Drive, you must be sure to be with the terminal in the extracted folder path, use the cd command if necessary. Then you must move the extracted directory in the path "/usr/lib/jvm" with the following command.

sudo mv ./jre1.7.0_25 /usr/lib/jvm/jre1.7.0_25

Now to install the JVM run the following command.

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0_25/bin/java 3

Now to see how many Java installations are available on the system run the following command. This step is required because this way you can choose the Java version you are installing as the default choice.

sudo update-alternatives --config java

Therefore, at this point in the terminal you should have something like.

Selezione    Percorso                                  Priorità  Stato
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 modalità automatica
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 modalità manuale
2 /usr/lib/jvm/jre1.7.0_25/bin/java 3 modalità manuale

Premere Invio per mantenere il valore predefinito[*] o digitare il numero della selezione:

In this case, the JVM version 1.7.0 u25 is listed at the selection number "2", to select this JVM as the default you must insert the number "2" in the terminal and push Enter. At this point, you should get a confirmation message like.

update-alternatives: viene usato /usr/lib/jvm/jre1.7.0_25/bin/java per fornire /usr/bin/java (java) in modalità manuale.

To test if everything is fine write the following command.

java –version

You should get something like.

java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode)

If instead of the version in the terminal you have something that tells you about a nonexistent file or directory;

-bash: ./java: File o directory non esistente

run the following command, which should solve the issue by installing a missing file.

sudo apt-get install libc6-i386

With this method you set the default JVM launched from the terminal but if you try to run a jar file by double click, the archive manager would be probably executed and even if you right click on the jar file; in the pop up context menu there is an element that says to run the jar file with an older Java version. So, if you want to run a jar file it is good to use the terminal with a command like.

java –jar jSnake.jar

Remember to move where is located the jar file you want to run. If there are issues, you can try to find answers in the Ubuntu web site; if instead everything works fine you can delete the tar.gz file downloaded at the beginning since the installed JVM works.

Java plug-in installation for Firefox or Chrome

To install the Java plug-in for Firefox or Chrome browsers have a look at the following steps. You need this if for example you have to run an applet in a web site or an application that uses Java Webstart technology or even JavaFX based applications.

Write in the terminal the following command in this way you make the folder where to put the plug-in.

mkdir ~/.mozilla/plugins

Now it is good to remove the "IcedTea" plug-in. Surely will be asked to continue with the plug-in removal, to say "yes" write in the terminal "y" and therefore push Enter.

sudo apt-get remove icedtea6-plugin

Remove if exist an old version of the Java plug-in with the command.

rm ~/.mozilla/plugins/libnpjp2.so

In the final step, you must pay attention to the Operating System you are working. Is it 32 or 64 bit? With the following command, you make a link by telling the browser where is installed the Java plug-in.

For 32 bit Operating System.

ln -s /usr/lib/jvm/jre1.7.0_25/lib/i386/libnpjp2.so ~/.mozilla/plugins/

For 64 bit Operating System.

ln -s /usr/lib/jvm/jre1.7.0_25/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

How test for the Java plug-in visit the Oracle’s test page.

Home