Ubuntu – How to use apt to install 32-bit OpenJDK-7-JRE on Azure AMD64 Ubuntu Server 14.04 LTS (Trusty)

14.04aptjavaopenjdkserver

Ubuntu Server 14.04 LTS for Azure does not come with Java pre-installed.
The server architecture is AMD64.

I know that you cannot install both the x64 and x86 JREs side-by-side, and I only need the x86 version (application requirements, memory requirements, etc).

Both the x86 and x64 versions of OpenJDK-7-JRE are available directly from Ubuntu here:
http://packages.ubuntu.com/trusty/openjdk-7-jre
http://packages.ubuntu.com/trusty/i386/openjdk-7-jre/download

However, Ubuntu strongly recommends using a package manager (such as apt) to install the package, rather than downloading the binaries using a web-browser and manually copying to the destination machine.

Therefore, I've been trying to install from the command line, but I'm running into issues:

MyAdmin@Server01:~$ sudo apt-get install openjdk-7-jre:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package openjdk-7-jre
MyAdmin@Server01:~$

The installation is successful if I omit the i386, but then I get the 64-bit JRE by default – which is not what I need.

I've confirmed that the source is already added in /etc/apt/sources.list

deb http://security.ubuntu.com/ubuntu trusty-security main
deb-src http://security.ubuntu.com/ubuntu trusty-security main
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
# deb http://security.ubuntu.com/ubuntu trusty-security multiverse
# deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

Is there another package, library, or repository that I need to install or update, before I can proceed with the apt installation of the OpenJDK x86 JRE?

Best Answer

It turns out I needed to explicitly add support for 32-bit architecture to the system.

openjdk-7-jre:i386 installed successfully after I did this:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install openjdk-7-jre:i386

NOTE: ia32-libs and any other necessary prerequisites are automatically selected and installed when you install openjdk-7-jre:i386. There's no need to install ia32-libs manually, and it's best to install the automatically selected libraries to ensure you definitely get the right version etc.