B4J Tutorial [GCE] For Noobs, Part 5 - Installing the Java Runtime Environment (JRE)

Okay fellow Noobs, we’re at the point where we want to run our superduper fabulistic world changing app. We will need to have the Java Runtime installed on the VM instance. This requires running a few commands at the console prompt (that we learned about in the previous tutorial).

Before we begin there is one very important thing you NEED to do first! Get yourself a coffee or beer (or both) before moving on to the next steps.

Follow these steps to install the JRE onto the VM:
  • We need to refresh/update the list of available packages for installation. From the command line type the following and then press Enter

    sudo apt-get update

    There will be some lines of text displayed during the process before you are back at the command prompt.

  • Next, we install the default JRE. Type the following at the command line and then press Enter. When prompted with the ‘Do you want to continue’ question - type Y followed by Enter

    sudo apt-get install default-jre
We’re finished with the installation. You can finish your coffee (it should still be hot!) ;)

What just happened? What did we do?

Okay, for the first step...
sudo - is a command that allows you to run the immediately following command (on the same line) at a higher privilege level (aka as a root user or superuser (su))

Next is ‘apt-get’ which is a commonly used command to install/manage applications on some distributions of Linux.

Note: Not all versions of Linux use apt-get. Some versions use ‘yum’. If apt-get does not work then try replacing apt-get with yum. yum may also use different options to install packages - if yum doesn’t recognise the options used by apt-get then you will need to look up the options and Google will be a good place to start :)

In the first step we follow apt-get with ‘update’. This is just one option for the apt-get command and it is used to update the list of installation packages available.

So what we did is update the available installation packages using apt-get and we did it as a superuser.

For the second step instead of ‘update’ we used ‘install’ and followed that by ‘default-jre’. So the option being passed now to apt-get is to ‘install’ the ‘default-jre’ package and again we did this running the command as superuser.

When the installation is completed you will be back at the command line prompt and JRE will have been installed and be running. You can check if the JRE is installed and running by typing in the following command and pressing Enter.

java -version

This will display the currently installed version of the JRE.

Very Cool!

Note: The more recent the Linux distribution is the more recent the jre will be. It is almost always preferable to use the most recent version of a Linux distribution.