しもむブログ

技術メモ。といっても高度なことは書けないので…初心者がハマったところや、ググってもすぐには出てこないようなものを書くつもり。

OpenBlocks IoT EX1 バージョン 8(jessie)にOpenJDK8をインストールする

前提条件

  • OpenBlocks IoT EX1
  • Debian 8.11

失敗例

  • 無邪気に入れようとするがエラー
root@obsiot:~# apt-get install openjdk-8-jdk
Reading package lists... 0%Reading package lists... 100%Reading package lists... Done
Building dependency tree... 0%Building dependency tree... 0%Building dependency tree... 50%Building dependency tree... 50%Building dependency tree... 59%Building dependency tree... 90%Building dependency tree       
Reading state information... 0%Reading state information... 0%Reading state information... Done
Package openjdk-8-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'openjdk-8-jdk' has no installation candidate
  • 探してみるがなさそう
root@obsiot:~# apt-cache search jdk
libanimal-sniffer-java - JDK/API verification tools
libanimal-sniffer-java-doc - Documentation for Animal Sniffer
jvm-7-avian-jre - lightweight virtual machine using the OpenJDK class library
libcommons-math-java - Java lightweight mathematics and statistics components
libcommons-math-java-doc - Java lightweight mathematics and statistics components - documentation
libcommons-math3-java - Java lightweight mathematics and statistics components
libcommons-math3-java-doc - Java lightweight mathematics and statistics components - documentation
fakeroot-ng - Gives a fake root environment
freemind - Java Program for creating and viewing Mindmaps
gcj-4.8-jdk - GCJ and Classpath development tools for Java(TM)
gcj-4.9-jdk - GCJ and Classpath development tools for Java(TM)
gcj-jdk - gcj and Classpath development tools for Java(TM)
libhessian-java - Java implementation of a binary protocol for web services
libhessian-java-doc - Documentation for libhessian-java
icedtea-7-plugin - web browser plugin based on OpenJDK and IcedTea to execute Java applets
libicu4j-java - Library for Unicode support and internationalization
libicu4j-4.4-java - Library for Unicode support and internationalization
libicu4j-49-java - Library for Unicode support and internationalization
japitools - Java API compatibility testing tools
default-jdk - Standard Java or Java compatible Development Kit
default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
default-jre - Standard Java or Java compatible Runtime
default-jre-headless - Standard Java or Java compatible Runtime (headless)
gcj-native-helper - Standard helper tools for creating gcj native packages
java3ds-fileloader - Java3D 3DS File Loader
libjson-simple-java - Simple, lightweight and efficient JSON toolkit for Java
jtreg - Regression Test Harness for the OpenJDK platform
libcommons-collections3-java - Apache Commons Collections - Extended Collections API for Java
libcommons-collections4-java - Apache Commons Collections - Extended Collections API for Java
libcommons-collections4-java-doc - Documentation for Commons Collections 4
libcommons-lang-java - Commons Lang - an extension of the java.lang package
libcommons-lang-java-doc - Documentation for Commons Lang - an extension of the java.lang package
libcommons-lang3-java - Extension of the java.lang package (for Java 5+)
libcommons-lang3-java-doc - Documentation for extension of the java.lang package (for Java 5+)
libcommons-launcher-java - Apache Commons Launcher - Cross platform Java application launcher
libhibernate-commons-annotations-java - Hibernate Commons Annotations
libitext1-java - Java Library to generate PDF on the Fly
libjboss-common-java - The JBoss Common Project
libjboss-marshalling-java - alternative serialization API
libjxp-java - Java template engine/script processor
libnb-javaparser-java - Parser for the Java language which is good for use in tools
libpostgresql-jdbc-java - Java database (JDBC) driver for PostgreSQL
libpostgresql-jdbc-java-doc - Java database (JDBC) driver for PostgreSQL (documentation)
libreoffice - office productivity suite (metapackage)
libslf4j-java - Simple Logging Facade for Java
mauve - free test suite for the Java Class libraries
libmaven-enforcer-plugin-java - Maven build rule execution framework
mmake - Makefile generator for Java programs
icedtea-7-jre-jamvm - Alternative JVM for OpenJDK, using JamVM
openjdk-7-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-7-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-7-doc - OpenJDK Development Kit (JDK) documentation
openjdk-7-jdk - OpenJDK Development Kit (JDK)
openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-7-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries)
openjdk-7-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-7-source - OpenJDK Development Kit (JDK) source files
openjdk-7-jre-dcevm - Alternative VM for OpenJDK 7 with enhanced class redefinition
libpracticalxml-java - practical XML handling routines
substance - cross-platform look & feel for Swing applications
substance-doc - cross-platform look & feel for Swing applications - documentation
testng - testing framework for Java
libtrove-java - high performance collections for java
libtrove-java-doc - high performance collections for java
libtrove3-java - high performance collections for java
libtrove3-java-doc - high performance collections for java
usepackage - utility to manage environment variables from within dotfiles
uwsgi-app-integration-plugins - plugins for integration of uWSGI and application
uwsgi-plugin-jvm-openjdk-7 - Java plugin for uWSGI (OpenJDK 7)
uwsgi-plugin-jwsgi-openjdk-7 - JWSGI plugin for uWSGI (OpenJDK 7)
libvisualvm-jni - All-in-One Java Troubleshooting Tool (JNI libraries)
visualvm - All-in-One Java Troubleshooting Tool
libwagon-java - tools to manage Maven artifacts and deployment

やったこと

  • /etc/apt/sources.listを修正
root@obsiot:~# vi /etc/apt/sources.list

deb http://ftp.jp.debian.org/debian/ jessie main
deb-src http://ftp.jp.debian.org/debian/ jessie main

# deb http://ftp.jp.debian.org/debian/ jessie-backports main
# deb-src http://ftp.jp.debian.org/debian/ jessie-backports main

#deb http://ftp.jp.debian.org/debian/ jessie-updates main  #コメントアウト
#deb-src http://ftp.jp.debian.org/debian/ jessie-updates main  #コメントアウト

deb http://security.debian.org jessie/updates main
deb-src http://security.debian.org jessie/updates main

deb http://ftp.plathome.co.jp/pub/BX1/debian/jessie ./
deb http://archive.debian.org/debian jessie-backports main  #追記
  • ファイルを2つ作成
echo "Acquire::Check-Valid-Until false;" >/etc/apt/apt.conf.d/10-nocheckvalid
echo 'Package: *\nPin: origin "archive.debian.org"\nPin-Priority: 500' >/etc/apt/preferences.d/10-archive-pin
  • 更新してインストール
apt-get update
apt-get install -t jessie-backports openjdk-8-jre-headless ca-certificates-java
apt-get install -t jessie-backports openjdk-8-jdk openjdk-8-jre
  • OpenJDK7が入っていたので切り替える
root@obsiot:~# /usr/sbin/update-java-alternatives -l
java-1.7.0-openjdk-i386 1071 /usr/lib/jvm/java-1.7.0-openjdk-i386
java-1.8.0-openjdk-i386 1069 /usr/lib/jvm/java-1.8.0-openjdk-i386
root@obsiot:~# sudo /usr/sbin/update-java-alternatives -s java-1.8.0-openjdk-i386
update-alternatives: error: no alternatives for mozilla-javaplugin.so
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-8-openjdk-i386/jre/lib/i386/IcedTeaPlugin.so
  • バージョンの確認
root@obsiot:~# java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-1~bpo8+1-b11)
OpenJDK Server VM (build 25.171-b11, mixed mode)
root@obsiot:~# javac -version
javac 1.8.0_171
  • いいかんじでIoT(OpenBlocks)ネタが多くなってきた

参考