class SyncWrap::OpenJDK

Provision an OpenJDK via Linux distro managed packages.

For simplicity, this component only supports the full JDK (runtime and compiler) and not the JRE (runtime only). Note that on older Debian-based distros, installing 'openjdk-7-jdk' is necessary for javac, but ends up pulling X11 and leads to signficant system bloat. See:

bugs.launchpad.net/ubuntu/+source/openjdk-6/+bug/257857

As of Ubuntu 16.04, there is an 'openjdk-8-jdk-headless' package which this will use if applicable.

Host component dependencies: <Distro>

Oracle, Java, and OpenJDK are registered trademarks of Oracle and/or its affiliates. See openjdk.java.net/legal/openjdk-trademark-notice.html

Attributes

jdk_major_minor[RW]

The JDK major and/or minor version number, i.e “1.7” or “7” is 7. Marketing picked the version scheme.

Public Class Methods

new( opts = {} ) click to toggle source
Calls superclass method SyncWrap::Component.new
# File lib/syncwrap/components/open_jdk.rb, line 53
def initialize( opts = {} )
  @jdk_major_minor = 7

  super
end

Public Instance Methods

install() click to toggle source

Install distro packages, including development headers for JNI dependents like Hashdot.

# File lib/syncwrap/components/open_jdk.rb, line 75
def install
  case distro
  when RHEL
    dist_install( "java-1.#{jdk_major_minor}.0-openjdk",
                  "java-1.#{jdk_major_minor}.0-openjdk-devel" )
  when Debian
    if jdk_major_minor >= 8 &&
       distro.is_a?( Ubuntu ) &&
       version_gte?( distro.ubuntu_version, [16,4] )
      # FIXME: This jdk-headless package option may be(come)
      # available on upstream Debian as well.
      dist_install( "openjdk-#{jdk_major_minor}-jdk-headless" )
    else
      dist_install( "openjdk-#{jdk_major_minor}-jdk" )
    end
  when Arch
    dist_install( "jdk#{jdk_major_minor}-openjdk" )
  else
    raise ContextError, "Unknown distro type"
  end
end
jdk_dir() click to toggle source

Distro and version dependent JDK installation directory.

# File lib/syncwrap/components/open_jdk.rb, line 60
def jdk_dir
  case distro
  when RHEL
    "/usr/lib/jvm/java-1.#{jdk_major_minor}.0"
  when Debian
    "/usr/lib/jvm/java-#{jdk_major_minor}-openjdk-amd64"
  when Arch
    "/usr/lib/jvm/java-#{jdk_major_minor}-openjdk"
  else
    raise ContextError, "Unknown distro jdk_dir"
  end
end