Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.


Информация
titleДанная статья применима к:
  • Astra Linux Special Edition РУСБ.10015-01 (очередное обновление 1.7)


Аннотация

В данной статье представлена инструкция по установке и первичной настройке OpenJDK на Astra Linux Special Edition РУСБ.10015-01 (очередное обновление 7). (далее - ОС). На момент написания данной статьи в составе ОС доступны следующие версии OpenJDK:    

  • версия 11.0.9.1+1-1~deb10u2 - в базовом репозитории;
  • версия 11.0.11+9-1~deb10u1+b1 - в расширенном репозитории;
  • на установочном диске OpenJDK отсутствует.

Подробнее про структуру и использование репозиториев см. Репозитории Astra Linux Special Edition 1.7: особенности подключения и использования.

Установка пакетов

Step 1 – Search OpenJDK Packages
OpenJDK packages are available under native apt repositories. You can simply use apt-cache search command to search available java version for your Ubuntu system.

sudo apt update
sudo apt search openjdk
As per above output, you can see openjdk-11-* and openjdk-8-* is available in the package manager.

Step 2 – Install Java on Debian 10
Use the below command to install OpenJDK on your Debian 10 Buster systems using the package manager from the default repository. The below commands will install Java Development Kit (JDK) and Java Runtime Environment (JRE) both on your system. You can install JRE package only to setup Runtime Environment only.

Choose one of the below option to install Java on Debian 10:

Installing Java 14:
sudo apt install openjdk-14-jdk
Installing Java 11:
  1. Подключить базовый или расширенный репозиторий (см. Репозитории Astra Linux Special Edition 1.7: особенности подключения и использования);

  2. Обновить список пакетов:

    Command
    sudo apt update


  3. Опционально: установить актуальное обновление:

    Command
    sudo apt dist-upgrade


  4. Проверить доступные версии OpenJDK:

    Command
    apt policy openjdk-11-jdk


  5. Установить пакет старшей доступной версии:

    Command
  1. sudo apt install openjdk-11-jdk
Installing Java 8
  1. или установить пакет указанной версии:

    Command
    sudo apt install openjdk-
8
  1. 11-jdk

Step 3 – Configure Default Java Version
The newly installed OpenJDK Java 11 will be configured as default Java version. But in some cases, you may need to change the default Java version. Run the following command on terminal:
  1. = 11.0.9.1+1-1~deb10u2


Первичная настройка

  1. Если на компьютере ранее была устанвлена Java, то проверить правильность выбора активной версии:

    Command
    sudo update-alternatives --config java

    При необходимости - выбрать правильную активную версию в диалоге команды.

  2. Настроить автоматическую установку окружения Java после перезагрузки:

    Command
    echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" | sudo tee /etc/profile.d/java.sh


  3. Загрузить окружение Java в текущую пользовательскую сессию:

    Command
    source /etc/profile.d/java.sh


  4. Проверить версию активной Java:

    Command
    Title

update-alternatives –config java
This will list all configured Java versions on your system. Choose the appropriate version number as showing in below screenshot.

A star (*) shows the currently active version. Here I choose 0 for OpenJDK 11 and press enter.

Install Java on Debian 10 Buster

After installation of Java uses below command to verify the installed version of Java on your system.
  1. java -version
    openjdk version "11.0.
9.1
  1. 11"
2020
  1. 2021-
11
  1. 04-
04
  1. 20
    OpenJDK Runtime Environment (build 11.0.11+9
.1+1
  1. -post-
Debian
  1. AstraLinux-
1deb10u1
  1. 1deb10u1b1)
    OpenJDK 64-Bit Server VM (build
build
  1. 11.0.11+9
.1+1
  1. -post-
Debian
  1. AstraLinux-
1deb10u1
  1. 1deb10u1b1, mixed mode, sharing)

  1. Step 4 – Setup Java Environment

It is the best practice to set Java environment variable after installing java. To setup java environment variabless, add the following line to /etc/profile.d/java.sh.

echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" > /etc/profile.d/java.sh
Load the environment to current shell.

source /etc/profile.d/java.sh
Now, the JAVA_HOME will automatically set even after system reboot. Use the following command to check the environment variable value

echo $JAVA_HOME

/usr/lib/jvm/java-11-openjdk-amd64/