# Java \[Linux]

## Using Ubuntu

{% hint style="info" %}
The instruction was tested on Ubuntu distributions 18.04, 20.04, 22.04
{% endhint %}

{% tabs %}
{% tab title="Java 8" %}

```
apt-get -y update
```

Wait a while, this process may take 1-2 minutes. When finished, a prompt appears to enter commands on behalf of the user.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FuOuzxEfnF0vC9N9Gx1jm%2Fimage.png?alt=media&#x26;token=4769938d-7ce0-47f0-adc4-c78c493f8589" alt=""><figcaption></figcaption></figure>

Use universal command to install OpenJDK 8

```
sudo apt install -y openjdk-8-jdk
```

Waiting for all files to be downloaded and installed.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fautt9n5lliJQ3J4klEcM%2Fimage.png?alt=media&#x26;token=d87f58bd-8b30-468c-b3f4-4fa230ad0488" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Java 11" %}

```
apt-get -y update
```

Wait a while, this process may take 1-2 minutes. When finished, a prompt appears to enter commands on behalf of the user.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FByFKgs7QRYb4u4TmDgZ6%2Fimage.png?alt=media&#x26;token=19f58dd2-15d9-4a13-9c9c-f7fad2ba3371" alt=""><figcaption></figcaption></figure>

Use universal command to install OpenJDK 11

```
sudo apt install -y openjdk-11-jdk
```

Waiting for all files to be downloaded and installed.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fq1Gg7JFw3jjYevNJzRWb%2Fimage.png?alt=media&#x26;token=2d0c53c0-687a-42f5-8ea7-1c22c74e3f4e" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Java 17" %}

```
apt-get -y update
```

Wait a while, this process may take 1-2 minutes. When finished, a prompt appears to enter commands on behalf of the user.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fr6ExP3fJ3OjggAqj3nXU%2Fimage.png?alt=media&#x26;token=d1976faa-eda7-4285-8317-1f0e91fab3ef" alt=""><figcaption></figcaption></figure>

Use universal command to install OpenJDK 17

```
sudo apt install -y openjdk-17-jdk
```

Waiting for all files to be downloaded and installed.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FkTEbnZsffxXRMSBGcFYI%2Fimage.png?alt=media&#x26;token=d4fb8593-6297-4634-b87d-11f6f9cc460b" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Test" %}

```
java -version
```

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fdht1NSkGFgOgF4SPq00R%2Fimage.png?alt=media&#x26;token=1c19fe6e-bab0-4ae4-8698-2864b52ea4bc" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Removing" %}

```
apt-get -y purge openjdk* java*
```

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FPJ5dW0soS9pxkT7ogkOf%2Fimage.png?alt=media&#x26;token=71bf0143-4e0f-4e24-9e9f-49f7d77bdabb" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Debian usage

{% hint style="info" %}
Tutorial tested on Debian distributions
{% endhint %}

{% tabs %}
{% tab title="Java 8" %}

```
apt install apt-transport-https gnupg wget software-properties-common -y
```

We’re adding a repository.

```
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add -
```

```
add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
```

```
apt-get update
```

Installing OpenJDK 8.

```
apt-get install adoptopenjdk-8-hotspot -y
```

{% endtab %}

{% tab title="Java 11" %}

```
apt-get -y update
```

Wait a while, this process may take 1-2 minutes. When finished, a prompt appears to enter commands on behalf of the user.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FkWhrKo1zT0kZ0u2fNJyI%2Fimage.png?alt=media&#x26;token=1e23f96d-da93-44a1-93a4-475ba8c7d762" alt=""><figcaption></figcaption></figure>

Use universal command to install OpenJDK 11

```
apt-get install -y openjdk-11-jdk
```

Waiting for all files to be downloaded and installed.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FYScIzkg0JSOIY3XFUFQN%2Fimage.png?alt=media&#x26;token=3c10b5b4-4c0c-4851-ace7-1e833b15e181" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Java 17" %}

```
apt-get -y update
```

Wait a while, this process may take 1-2 minutes. When finished, a prompt appears to enter commands on behalf of the user.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FtccId6LffpFs4BZOaCOY%2Fimage.png?alt=media&#x26;token=410069fe-f590-42dd-86e3-072947d156e2" alt=""><figcaption></figcaption></figure>

Use universal command to install OpenJDK 17

```
apt-get install -y openjdk-17-jdk
```

Waiting for all files to be downloaded and installed.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fp2mgUGtcW4aWvt3ggoe6%2Fimage.png?alt=media&#x26;token=8ba39a5f-0548-401f-9966-b516686b39a7" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Test" %}

```
java -version
```

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fu5DItmEmgSEMon1LTCV4%2Fimage.png?alt=media&#x26;token=fc6fff8f-2ab3-47a7-b1e3-b0e1b2ee2b4a" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Removing" %}

```
apt-get -y purge openjdk* java*
```

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fw8l40ENvQeq6O3G57iqL%2Fimage.png?alt=media&#x26;token=e7160b76-62fa-40b9-b502-2615f9306d59" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}
