16
15

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.

Amazon Linuxにjdk1.7 or 1.8インストール

Last updated at Posted at 2014-11-10

ダウンロード&インストール

jdk8

$ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.rpm"
$ sudo rpm -ivh jdk-8u25-linux-x64.rpm

jdk7

$ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-x64.rpm"
$ sudo rpm -ivh jdk-7u72-linux-x64.rpm

ここからもダウンロードできます

jdk8

jdk7

インストール先

$ ll /usr/java/
total 4
lrwxrwxrwx 1 root root   16 Nov 10 15:40 default -> /usr/java/latest
drwxr-xr-x 9 root root 4096 Nov 10 15:40 jdk1.8.0_25
lrwxrwxrwx 1 root root   21 Nov 10 15:40 latest -> /usr/java/jdk1.8.0_25

バージョン指定実行コマンド作成

java8

$ sudo ln -s /usr/java/jdk1.8.0_25/bin/java /usr/bin/java8

java7

$ sudo ln -s /usr/java/jdk1.7.0_72/bin/java /usr/bin/java7

javaコマンドのリンクを変更

$ sudo rm /usr/bin/java
$ sudo ln -s /usr/bin/java8 /usr/bin/java

alternativesというのを使うといいみたいですが調べきれていません。

確認

$ java -version
java version "1.8.0_25"
16
15
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
16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?