6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vagrant Tips#2’ Oracleのjdkをインストールさせる(jdk8系)

Last updated at Posted at 2014-11-16

##Vagrant Tipsのサマリページはこちら

Vagrant Tips#2 Oracleのjdkをインストールさせる
のjava8版です。2015年の4月でjdk7のサポートが終了になるとのことなので、そろそろjava8をまじめに勉強しようと思います。

Vagrantfile
Vagrant::Config.run do |config|
  config.vm.box = "centos64_6_5"
  config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box"

  config.vm.provision "shell", path: "setup_jdk.sh"

end
setup_jdk.sh
#!/bin/bash

BASE_DIR="/vagrant"
RPM_DIR="${BASE_DIR}/rpm"
JDK_VERSION=8u73
BUILD_NO=b02
JAVA_RPM_NAME="jdk-${JDK_VERSION}-linux-x64.rpm"
JDK_DOWNLOAD_URL="http://download.oracle.com/otn-pub/java/jdk/${JDK_VERSION}-${BUILD_NO}/${JAVA_RPM_NAME}"

# create dir
if [ ! -d ${RPM_DIR} ]
then
  mkdir -p ${RPM_DIR}
else
  echo "${RPM_DIR} Is Already Exists So Need Not Create"
fi

# if "rpm for jdk file" is noting
if [ ! -f ${RPM_DIR}/${JAVA_RPM_NAME} ]
then
  wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" ${JDK_DOWNLOAD_URL}  -O /tmp/${JAVA_RPM_NAME}
  mv /tmp/${JAVA_RPM_NAME} ${RPM_DIR}/
else
  echo "${JAVA_RPM_NAME} Is Already Exists So Need Not Wget"
fi

# install jdk
sudo rpm -ivh ${RPM_DIR}/${JAVA_RPM_NAME}
6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?