How to install openjdk-8-jdk on Debian 10 (Buster)?

后端 未结 9 1365
别跟我提以往
别跟我提以往 2020-12-23 09:06

It seems Debian does not support openjdk-8-jdk anymore due to a security issue. What is the easiest way to install openjdk-8-jdk for Debian 10 (Buster)?

相关标签:
9条回答
  • 2020-12-23 09:50

    This is my script which I use to install OpenJDK 8 on Bitbucket's Pipelines Docker image NodeJS 10.16.2. But now I see that this docker image is based on Stretch...

    It is based on https://github.com/docker-library/openjdk/blob/89851f0abc3a83cfad5248102f379d6a0bd3951a/8-jdk/Dockerfile

    #!/bin/bash
    set -x #echo on
    # based on https://github.com/docker-library/openjdk/blob/89851f0abc3a83cfad5248102f379d6a0bd3951a/8-jdk/Dockerfile
    
    apt-get update && apt-get install -y --no-install-recommends \
      bzip2 \
      unzip \
      xz-utils &&
      rm -rf /var/lib/apt/lists/*
    
    echo 'deb http://httpredir.debian.org/debian-security stretch/updates main' >/etc/apt/sources.list.d/jessie-backports.list
    
    # Default to UTF-8 file.encoding
    export LANG=C.UTF-8
    
    # add a simple script that can auto-detect the appropriate JAVA_HOME value
    # based on whether the JDK or only the JRE is installed
    { \
        echo '#!/bin/sh'; \
        echo 'set -e'; \
        echo; \
        echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
    } > /usr/local/bin/docker-java-home \
    && chmod +x /usr/local/bin/docker-java-home
    
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
    export JAVA_VERSION=8u252
    export JAVA_DEBIAN_VERSION=8u252-b09-1~deb9u1
    
    # see https://bugs.debian.org/775775
    # and https://github.com/docker-library/java/issues/19#issuecomment-70546872
    export CA_CERTIFICATES_JAVA_VERSION=20170929~deb9u3
    
    set -x \
        && apt-get update \
        && apt-get install -y \
            openjdk-8-jdk="$JAVA_DEBIAN_VERSION" \
            ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
        && rm -rf /var/lib/apt/lists/* \
        && [ "$JAVA_HOME" = "$(docker-java-home)" ]
    
    # see CA_CERTIFICATES_JAVA_VERSION notes above
    /var/lib/dpkg/info/ca-certificates-java.postinst configure
    
    

    UPDATE

    Things change, versions are upped. Here is the latest script which works for https://hub.docker.com/layers/node/library/node/10.16.2/images/sha256-8f420c033acee137f9e902092a04d371bdf1f839559cce60614c0d5905d20294?context=explore

    #!/bin/bash
    set -x #echo on
    # based on https://github.com/docker-library/openjdk/blob/89851f0abc3a83cfad5248102f379d6a0bd3951a/8-jdk/Dockerfile
    
    apt-get update && apt-get install -y --no-install-recommends \
      bzip2 \
      unzip \
      xz-utils &&
      rm -rf /var/lib/apt/lists/*
    
    echo 'deb http://httpredir.debian.org/debian-security stretch/updates main' >/etc/apt/sources.list.d/jessie-backports.list
    
    # Default to UTF-8 file.encoding
    export LANG=C.UTF-8
    
    # add a simple script that can auto-detect the appropriate JAVA_HOME value
    # based on whether the JDK or only the JRE is installed
    { \
        echo '#!/bin/sh'; \
        echo 'set -e'; \
        echo; \
        echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
    } > /usr/local/bin/docker-java-home \
    && chmod +x /usr/local/bin/docker-java-home
    
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
    export JAVA_VERSION=8u265
    export JAVA_DEBIAN_VERSION=8u265-b01-0+deb9u1
    
    # see https://bugs.debian.org/775775
    # and https://github.com/docker-library/java/issues/19#issuecomment-70546872
    export CA_CERTIFICATES_JAVA_VERSION=20170929~deb9u3
    
    set -x \
        && apt-get update \
        && apt-get install -y \
            openjdk-8-jdk="$JAVA_DEBIAN_VERSION" \
            ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
        && rm -rf /var/lib/apt/lists/* \
        && [ "$JAVA_HOME" = "$(docker-java-home)" ]
    
    # see CA_CERTIFICATES_JAVA_VERSION notes above
    /var/lib/dpkg/info/ca-certificates-java.postinst configure
    
    0 讨论(0)
  • 2020-12-23 09:57

    the easiest way I have found to download java 8 on debian buster is to use the command su apt-get install openjdk-8-jdk

    0 讨论(0)
  • 2020-12-23 10:02

    I needed to install a 32-bit version but this wasn't available at adoptopenjdk far as I could see. I tracked down a copy of a binary at java.com i their downloads area:

    jre-8u241-linux-i586.tar.gz
    

    All I needed was the JRE (rather than a JDK, but the process should be the same for either) and since it was also for a personal use only, the Oracle binary was OK (they have limitations in this regard).

    I downloaded the binary and placed it in the home folder (~/) of the user that needed to run it and then unzipped it like so:

    mkdir ~/java && cd ~/java && tar -xf jre-8u241-linux-i586.tar.gz
    

    Then added the location to the path of the user that would run the Java application by appending this line to ~/.profile:

    export PATH=$PATH:/home/youruserid/java/jre1.8.0_241/bin
    

    This worked fine for my case but there are no doubt better ways to install a binary. For example so it is available for all Unix users rather than just one.

    0 讨论(0)
提交回复
热议问题