@JS's Notes

Site with notes from my work.

How to install Java on Debian 10

2019-10-06 System @JS

Requirements: user with root privileges or non-root user with sudo privileges.

OpenJDK installation
$ sudo apt update && sudo apt upgrade -y
$ sudo apt install default-jdk
$ java -version
Oracle Java 12 installation
$ sudo echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main" | sudo tee etc/apt/sources.list.d/linuxuprising-java.list
$ sudo apt install dirmngr
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A
$ sudo apt update
$ sudo apt install oracle-java12-installer
$ java -version
Setting the JAVA_HOME environment variable
$ sudo update-alternatives --config java

Add the following line in /etc/environment:

JAVA_HOME="/usr/lib/jvm/java-12-oracle"

Then source it as follows:

$ sudo source /etc/environment
$ echo $JAVA_HOME
/usr/lib/jvm/java-12-oracle