V
V
Vincent2020-05-04 22:13:47
Java
Vincent, 2020-05-04 22:13:47

How to install java on ubuntu?

The fact is that I have already installed everything that is possible (I need version 8).

sudo apt list openjdk*
openjdk-11-dbg/bionic-updates,bionic-security 11.0.7+10-2ubuntu2~18.04 amd64
openjdk-11-demo/bionic-updates,bionic-security 11.0.7+10-2ubuntu2~18.04 amd64
openjdk-11-doc/bionic-updates,bionic-updates,bionic-security,bionic-security 11.0.7+10-2ubuntu2~18.04 all
openjdk-11-jdk/bionic-updates,bionic-security 11.0.7+10-2ubuntu2~18.04 amd64
openjdk-11-jdk-headless/bionic-updates,bionic-security 11.0.7+10-2ubuntu2~18.04 amd64
openjdk-11-jre/bionic-updates,bionic-security 11.0.7+10-2ubuntu2~18.04 amd64
openjdk-11-jre-dcevm/bionic-updates,bionic-security 11.0.1+8-1~18.04.1 amd64
openjdk-11-jre-headless/bionic-updates,bionic-security,now 11.0.7+10-2ubuntu2~18.04 amd64 [остались файлы настроек]
openjdk-11-jre-zero/bionic-updates,bionic-security 11.0.7+10-2ubuntu2~18.04 amd64
openjdk-11-source/bionic-updates,bionic-updates,bionic-security,bionic-security 11.0.7+10-2ubuntu2~18.04 all
openjdk-8-dbg/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [установлен]
openjdk-8-demo/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [установлен]
openjdk-8-doc/bionic-updates,bionic-updates,bionic-security,bionic-security,now 8u252-b09-1~18.04 all [установлен]
openjdk-8-jdk/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [установлен]
openjdk-8-jdk-headless/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [установлен]
openjdk-8-jre/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [установлен]
openjdk-8-jre-dcevm/bionic,now 8u112-2 amd64 [установлен]
openjdk-8-jre-headless/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [установлен]
openjdk-8-jre-zero/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [установлен]
openjdk-8-source/bionic-updates,bionic-updates,bionic-security,bionic-security,now 8u252-b09-1~18.04 all [установлен]

I enter java into the terminal
and get

Command 'java' not found, but can be installed with:

sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless


If you do this:
'/usr/bin/java'
will issue
bash: /usr/bin/java: Нет такого файла или каталога

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2020-05-04
@wintreist

Hello!
Given that you do not need Java for development and jre will be enough, then you will not need sdkman.
However, pay attention to the following:
1) whether java is installed
2) whether system variables are correctly registered
To begin with:
Type and find out the version
java -version
If it shows the version, then everything is ok. And if not, then you most likely do not have java installed.
Going further (installing java):

sudo apt update
sudo apt install openjdk-11-jre

Also sometimes multiple jre and jdk can be installed.
Type in the console:
sudo update-alternatives --config java
In the console you will see the path to the java directory. If there are several of them, then copy the desired path, and then:
Open the editor:
sudo nano /etc/environment
Add:
JAVA_HOME="{путь, который скопировали, включая директорию bin}"

We close the editor and reload the file
source /etc/environment
We type in the console:
echo $JAVA_HOME
If the path is displayed, then everything is ok.
Link to source - https://www.digitalocean.com/community/tutorials/h...

D
Dmitry Roo, 2020-05-04
@xez

The best way to install Java on a development machine is through sdkman:
https://sdkman.io/
I use it myself and recommend it to everyone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question