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

后端 未结 9 1364
别跟我提以往
别跟我提以往 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:41

    I was migrating from Jessie to Buster, and found that not-so-old, legacy code would not compile and run on JDK11.

    I managed to copy all java8 folders from my Jessie distribution, reworked the links, and set that as a new JDK on Eclipse. That works so far.

    0 讨论(0)
  • 2020-12-23 09:44

    The easiest way to install JDK8 is using SDKMAN.

    $ curl -s "https://get.sdkman.io" | bash
    $ source "$HOME/.sdkman/bin/sdkman-init.sh"
    $ sdk install java 8.0.275.hs-adpt
    
    0 讨论(0)
  • 2020-12-23 09:45

    I found this way. Add in your sources.list:

    sudo vim /etc/apt/sources.list
    

    The following repo:

    deb http://ftp.us.debian.org/debian sid main
    

    Then:

    sudo apt-get update
    

    Last:

    sudo apt-get install openjdk-8-jdk
    

    Additional steps:

    sudo update-alternatives --config java
    

    Choose your java version.

    https://packages.debian.org/sid/openjdk-8-jdk

    0 讨论(0)
  • 2020-12-23 09:47

    You can search the Debian packages site and find out the openjdk-8-jdk package for Debian 10 is only available from unstable (sid) repository currently.

    At first it is good to check and save current system-wide symbolic links for already installed Java SDK/JRE packages if any:

    ls -la /etc/alternatives | grep java > previous-java-alternatives.txt
    

    Then check is this package can be installed with current configuration:

    apt-cache policy openjdk-8-jdk
    

    If no then you need to add unstable repository to the sources list. The negative output may imply that you prefer to use stable repositories and usually it isn't appropriate for you to update all other software from unstable repositories. So before adding unstable repository to the sources list make sure APT::Default-Release configuration option is set to "stable":

    grep -r Default-Release /etc/apt/
    

    If no (as by default) then set it as recommended in that answer by creating this file:

    /etc/apt/apt.conf.d/99defaultrelease

    APT::Default-Release "stable";
    

    Now you're ready to add the unstable repository to the sources list. Before I prefer to check what mirror was selected by me when system was installed. Just look to main sources list:

    cat /etc/apt/sources.list
    

    In my case the output shows that mirror.yandex.ru server is used as system source. So I use the same for unstables and add this file:

    /etc/apt/sources.list.d/91-debian-unstable.list

    deb http://mirror.yandex.ru/debian/ unstable main
    deb-src http://mirror.yandex.ru/debian/ unstable main
    

    (I also have 90-debian-testing.list file for the testing repo.)

    Then update package lists:

    apt update
    

    And check you system wont update from unstable sources:

    apt list --upgradable
    

    And recheck is required package can be installed:

    apt-cache policy openjdk-8-jdk
    

    Do install the package:

    apt install openjdk-8-jdk
    

    Look at new symbolic links:

    ls -la /etc/alternatives | grep java-8
    

    Just waste few seconds on them (or continue with man 1 update-alternatives).

    0 讨论(0)
  • 2020-12-23 09:48

    Alternatively, you can use adoptopenjdk repository:

    wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
    
    sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
    
    sudo apt-get update && sudo apt-get install adoptopenjdk-8-hotspot
    

    https://adoptopenjdk.net/installation.html

    0 讨论(0)
  • 2020-12-23 09:49

    Package mirror search steps:

    1. In the Search package directories search for openjdk-8-jdk. You can see two results:

      • stretch (oldstable) (java): OpenJDK Development Kit (JDK)
      • sid (unstable) (java): OpenJDK Development Kit (JDK)
    2. Choose stretch repository

    3. Scroll to the Download openjdk-8-jdk section and choose your architecture. For example amd64
    4. Now you can see mirrors list and instructions how to install the package via apt:

      You should be able to use any of the listed mirrors by adding a line to your /etc/apt/sources.list like this:

      deb http://security.debian.org/debian-security stretch/updates main

    Installation steps:

    1. Install software source manager

      apt-get update
      apt-get install software-properties-common
      
    2. Add mirror with openjdk-8-jdk

      apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main'
      apt-get update
      
    3. Install openjdk 8

      apt-get install openjdk-8-jdk
      

    Note: You can use steps above to find an official Debian mirror with any other package you want to install

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