Help us understand the problem. What is going on with this article?

JDK 7とJDK 8を切り替える

More than 1 year has passed since last update.

JDK 7とJDK 8を切り替えてる方法

JDKを探す

コマンドでパッケージを検索してみましょう。

$ yum search openjdk
Loaded plugins: priorities, update-motd, upgrade-helper
12 packages excluded due to repository priority protections
======================= N/S matched: openjdk =============
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed in single archive
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle

JDK1.8をインストール

$ yum install java-1.8.0-openjdk
#
# インストールした Java のバージョンが表示されれば確認終了です。
#
$ java --version
java version "1.8.0_141"

JDK 7→JDK 8の場合に

$ java -version
#
# output
# java version "1.7.0_151"
# ....
#
$ alternatives --config java
#
# output
#
# There are 3 programs which provide 'java'.
# 
#   Selection    Command
# -----------------------------------------------
# *+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
#    2           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
#    3           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
#
# Enter to keep the current selection[+], or type selection number:
#
# input 2
$ java -version
#
# output
# openjdk version "1.8.0_141"
# ......

JDK 8 → JDK 7の場合に

$ java -version
#
# output
# java version "1.8.0_141"
# ....

$ alternatives --config java
#
# output
#
# There are 3 programs which provide 'java'.
# 
#   Selection    Command
# -----------------------------------------------
# *  1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
#  + 2           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
#    3           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
#
# Enter to keep the current selection[+], or type selection number:
#
# input 1
$ java -version
# output
# openjdk version "1.7.0_151"
# ......

end

皆様のお仕事の役に立てれば幸いです。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away