Introduction

How to install Java on Ubuntu Linux? Although, this topic is a quite self explanatory to an experienced Linux system administrator it still creates lots of confusion for beginners in terms what version of Java I need, how do I install it or how to change my system settings between multiple different types of Java versions. The aim of this short article is to shed some light on this topic as we will show how to install Java JDK for both Oracle and as well as OpenJDK.

What is Java

In short, Java is an object-oriented programming language. The current owner of the official implementation of the Java SE ( Standard Edition ) platform is Oracle Corporation. The free and open source implementation of the Java Platform SE is called OpenJDK and OpenJRE. There is also another Java version maintained by IBM. IBM provides also both JDK and JRE. Currently only OpenJDK and OpenJRE Java versions are available via standard Ubuntu repository.

The following quick tutorial will provide you with the information on how to configure LAMP ( Linux, Apache, MySQL, PHP ) server on the Ubuntu 16.04 Xenial Xerus Linux. This guide consists of the three simple to follow steps: installation, database setup and testing.

Installation

Let's begin by installation of all required packages:
$ sudo apt-get update
$ sudo apt-get install libapache2-mod-php php-mysql mysql-server apache2

The following guide will provide you with some information on how to improve Ubuntu's repository download speed by selecting the closest, that is, possibly fastest mirror relative to your geographical location.

Country Code

The simplest approach is to make sure that your Ubuntu mirror defined within /etc/apt/sources.list includes a relevant country code appropriate to your location. For example, below you can find a official United States Ubuntu mirror as found in /etc/apt/sources.list:
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
If you are not located in United States simply overwrite the us country code with appropriate code of your country. That is, if your are located for example in Australia update your /etc/apt/sources.list file for all entries as:
deb http://au.archive.ubuntu.com/ubuntu/ xenial main restricted

Use mirror protocol

Using mirror protocol as part of your /etc/apt/sources.list entry will instruct apt command to fetch mirrors located within your country only. In order to use mirror protocol update all lines within /etc/apt/sources.list file from the usual eg.:
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted

Why LXD?

It’s no secret that containers are hot right now in the Linux world. They are quickly becoming the backbone of the Cloud and are making DevOps dreams come true. Even so, at first glance, it seems a bit redundant for Canonical to develop a new container system for Ubuntu in a world easily dominated by Docker. So why, then, did they do it? To fill a middle ground between traditional virtual machines and Docker. Canonical said it themselves, “By combining the speed and density of containers with the security of traditional virtual machines, Canonical’s LXD is the next‐generation of container hypervisor for Linux.” Not only that, but Docker containers can be run within LXD containers, adding another dimension to potential container configurations.

LXD is an enhancement of the existing LXC Linux container hypervisor with it’s own toolset, sharing a similar relationship to the original project as Ubuntu does with Debian with the goal of taking existing great software and streamlining it for easier use. On Canonical’s latest Ubuntu LTS release, 16.04, LXD is well integrated and easy to use with clear and concise CLI tools that make container creation and management seamless.

Initial Setup

Getting started with LXD on Ubuntu 16.04 is as close to effortless as could be expected. Canonical condensed the install to a single package, making this a one command install. A simple sudo apt-get install lxd will get everything needed to get started.

Install LXD with apt-get install lxd

The following config will guide you through the process of enabling SSH root login on Ubuntu 16.04 Xenial Xerus Linux Server or Desktop. This guide assumes that you are in possession of root password and are able to login directly on your system as root user. Use the following guide, if you do not have a root's user password.

By default the root's ssh remote shell access is denied by default. Any attempt to remote login as root will result in Permission denied message:
$ ssh This email address is being protected from spambots. You need JavaScript enabled to view it.
	
This email address is being protected from spambots. You need JavaScript enabled to view it.'s password: 
Permission denied, please try again.
This email address is being protected from spambots. You need JavaScript enabled to view it.'s password:

ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME or create a JOB ALERT on LinuxCareers.com job portal.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.