# 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="/files/KGuCCX1qgSE2pntoPanK" 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="/files/O9ZBAc553bB0Xl5nPQDj" 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="/files/J8fzcNkXrYiSStbQvMCy" 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="/files/8yQBjo2RSsi50rgZOWHT" 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="/files/RAemFfbiAnYJKy3DNE3p" 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="/files/Yc26BILapN4RlLZlagSr" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Test" %}

```
java -version
```

<figure><img src="/files/tuLzlXVCzADFwID04C4D" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Removing" %}

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

<figure><img src="/files/1K3r3iV38IuV79lPRKto" 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="/files/xja48LYCMIIiMqCr4jsv" 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="/files/03GKQAtbuDYzGwoVJtQZ" 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="/files/CxncF6jMCnmZQABQt5df" 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="/files/fLuv7JLZvP3PNyafpFYp" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Test" %}

```
java -version
```

<figure><img src="/files/M6M1aRxVU6MSsz7rHVQ0" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Removing" %}

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

<figure><img src="/files/0hazG26orobZZ2VTcLEV" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://spacecore.gitbook.io/wiki/en/os-and-software/java-linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
