Java8 on Ubuntu 14.04

deeksha sharma
Algorithm Problems
Published in
2 min readJul 11, 2016

There are 2 ways of creating your own Java8 docker file depending upon the distribution.

  • If we use openjdk then we need to fetch the tar.gz of java8 from PPA repository. Below is the Docker file for Java8 from Openjdk
# Add the base Image as Ubuntu14.04
FROM ubuntu:14.04
#Download the package lists and update their newest versions
#Install software-properties-common package that manage the repositories from which softwares are installed
RUN apt-get update && apt-get install -y software-properties-common
# Get openjdk-jre from ppa repository
RUN add-apt-repository ppa:openjdk-r/ppa
# Install wget and openjdk8-jre
RUN apt-get update && apt-get install -y openjdk-8-jdk && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
# Set Java home in the environment variable
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
  • If we want to use Java Distribution from Oracle then we have to fetch the tar.gz of Java8 from Oracle website. However Oracle does not allow you to download its distribution without license agreement. So we will see how can we do so.
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y wget
RUN mkdir /opt/java && \
wget -qO- --header "Cookie: oraclelicense=accept-securebackup-cookie" --no-check-certificate http://javadl.oracle.com/webapps/download/AutoDL?BundleId=207765 | tar zxv -C /opt/java
ENV JAVA_HOME /opt/java/jre1.8.0_91
RUN export JAVA_HOME
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Build ImageUse the following command to build the Java Docker image. The below command assumes that you have placed the Docker file inside a Java directory on your machine.docker build -t deeksha/java java/

--

--

deeksha sharma
Algorithm Problems

Work for https://bonsaiilabs.com/ life long learner ,investing time heavily in personal finance, education, tech and design skills. Twitter: @deekshasharma25