title: Install java 8 (jdk 1.8) using "vagrant up" not working on debian
body: <p>When I am Running My Vagrantfile with its shell, I'm struggle with Java 8 install with this exact same error :</p>
  
  <p><a href="https://stackoverflow.com/questions/46815897/jdk-8-is-not-installed-error-404-not-found">StackOverflow - jdk-8-is-not-installed-error-404-not-found</a></p>
  
  <p>In order to fix that error, I added those lines :</p>
  
  <pre><code>sudo sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' /var/lib/dpkg/info/oracle-java8-installer.*
  sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' /var/lib/dpkg/info/oracle-java8-installer.*
  sudo sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' /var/lib/dpkg/info/oracle-java8-installer.*
  sudo sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' /var/lib/dpkg/info/oracle-java8-installer.*
  </code></pre>
  
  <p>I have in my Shell this block for java section:</p>
  
  <pre><code># /*======================
  # =            JAVA      =
  # ======================*/
  # https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8
  sudo apt-get install -y software-properties-common
  echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
  echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
  sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
  sudo apt-get update
  
  # Silent !! Sshh !
  echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
  echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
  
  # see https://stackoverflow.com/questions/46815897/jdk-8-is-not-installed-error-404-not-found
  # Still not work
  sudo sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' /var/lib/dpkg/info/oracle-java8-installer.*
  sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' /var/lib/dpkg/info/oracle-java8-installer.*
  sudo sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' /var/lib/dpkg/info/oracle-java8-installer.*
  sudo sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' /var/lib/dpkg/info/oracle-java8-installer.*
  
  sudo apt-get install -y oracle-java8-installer
  sudo apt-get install -y oracle-java8-set-default
  </code></pre>
  
  <p>The weird thing is : Those lines taken one by one via SSH when the box is started and you can install Java, it Works. But it's not working when I provision for the first time my vagrant box.</p>
  
  <p>Is the problem comes from sed or another command ? I suppose it's the sed's command but don't know how to fix it, because it's working if I paste them via SSH.</p>
  
  <p>I want to make this work without any manual interventions.</p>
  
  <p>You can test my VM using this github repo (V2) :
  <a href="https://github.com/jonathangreco/vagrant-file/tree/master/V2" rel="nofollow noreferrer">VagrantFile + shells</a></p>
  
  <p>How can I make this work using vagrant up ?</p>
  
  <p>EDIT :</p>
  
  <ul>
  <li>I've tested it on Vagrant 2.0 and virtualBox 5.6</li>
  <li>Also tested with vagrant 1.7 and virtualBox 5.1</li>
  </ul>