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

ラズパイでJava8を使う

More than 3 years have passed since last update.

自分のRaspberry Piに、Java8をインストールしたので、メモを残しておきます。特に、難しいことはありませんでした。

事前確認

現在のJavaインストール状態を確認します。Java7がインストールされていました。

$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)
$
$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Jan  8  2014 /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 44 Jan  8  2014 /etc/alternatives/java -> /usr/lib/jvm/jdk-7-oracle-armhf/jre/bin/java
$ ls -l /usr/lib/jvm/jdk-7-oracle-armhf/jre/bin/java
-rwxr-xr-x 1 root root 5924 Aug 27  2013 /usr/lib/jvm/jdk-7-oracle-armhf/jre/bin/java
$
$ dpkg -l | grep jdk
ii  oracle-java7-jdk                      1.7.0+update40                          armhf        Java? Platform, Standard Edition 7 Development Kit

aptでインストール可能なJavaを確認します。Java8がインストールできることを確認できました。

$ apt-cache search oracle jdk
oracle-java7-jdk - Java? Platform, Standard Edition 7 Development Kit
oracle-java8-jdk - Java? Platform, Standard Edition 8 Development Kit

OSアップデート

以降の作業を安定して進めるため、次のコマンドでOSをアップデートしました。

$ sudo apt-get update

Java8インストール

次のコマンドでインストールしました。

$ sudo apt-get install oracle-java8-jdk
$ dpkg -l | grep oracle
ii  oracle-java7-jdk                      1.7.0+update40                          armhf        Java? Platform, Standard Edition 7 Development Kit
ii  oracle-java8-jdk                      8                                       armhf        Java? Platform, Standard Edition 8 Development Kit
$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)
$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22  1月  8  2014 /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 51  5月 14 21:47 /etc/alternatives/java -> /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java
$ ls -l /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java
-rwxr-xr-x 1 root root 5912  3月  5  2014 /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java

設定

環境変数JAVA_HOMEを使用するアプリケーションのため、次の設定をしておきます。

$ JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt

もし、今回インストールする前のJava7を使いたい場合は、次の設定で使えるようになります。

$ JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf
$ PATH=${JAVA_HOME}/bin:${PATH}
$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)
Why not register and get more from Qiita?
  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
No 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
ユーザーは見つかりませんでした