JDK installation in linux (Ubuntu, Centos)

To download jdk for now, you need:

1) go to java.sun.com (browser will redirect you to right path). 2) create account if you do not have 3) download latest JDK8 version 4) copy jdk archive into ${HOME} directory.


Install packages for installation

// Ubuntu
$ sudo apt-get install -y \
vim \
unzip \
tar \
wget


// Centos
$ sudo yum install -y \
vim \
unzip \
tar \
wget


Installation JDK8 in linux

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

$ ls jdk*
jdk-8u241-linux-x64.tar.gz

$ tar -xvzpf jdk-8u241-linux-x64.tar.gz
$ sudo mv jdk1.8.0_241/ /opt/
$ sudo ln -s /opt/jdk1.8.0_241/ /opt/jdk


$ rm jdk-8u241-linux-x64.tar.gz


$ sudo vi /etc/profile.d/java.sh


#### JDK8 #######################

export JAVA_HOME=/opt/jdk
export PATH=${JAVA_HOME}/bin:$PATH

#### JDK8 #######################


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


Let try to check result:


$ java -version
java version "1.8.0_241"


OpenJDK installation in linux

$ sudo apt-get update
$ sudo apt-get install -yq openjdk-8-jdk

// get possible jdk locations
$ sudo update-alternatives --config java

// specify jdk location
$ sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

$ java -version


also you can install maven from packages

$ sudo apt-get install -yq maven