Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

StepAction

1) Update and Upgrade OS
and get Oracle JDK

Warning
titleJava version

The current version of java-8 may vary. Please adapt the following settings to the current version



Code Block
languagebash
sudo apt update
sudo apt upgrade
sudo reboot -p -f

download Oracle JDK  (Example filename jdk-8u241-linux-x64.tar.gz) and upload the file /opt/Download

2) Creating workspace


Code Block
languagebash
sudo mkdir /usr/lib/jvm


3) Extracting JDK


Code Block
languagebash
cd /usr/lib/jvm
sudo tar xzf /opt/Download/jdk-8u241-linux-x64.tar.gz
sudo ln -s jdk1.8.0_241 current
sudo chown -R root:root jdk1.8.0_241


3) Setting up environment variables





Code Block
languagebash
sudo vi /etc/environment


Code Block
languagebash
title/etc/environnement
linenumberstrue
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/jdk1.8.0_241current/bin:/usr/lib/jvm/jdk1.8.0_241current/db/bin:/usr/lib/jvm/jdk1.8.0_241current/jre/bin"
J2SDKDIR="/usr/lib/jvm/jdk1.8.0_241current"
J2REDIR="/usr/lib/jvm/jdk1.8.0_241current/jre"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_241current"


5) Configuring the Java location

Enter the following commands to inform the system of the Java location.


Code Block
languagebash
linenumberstrue
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_241current/bin/java" 0
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_241current/bin/javac" 0
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_241current/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_241current/bin/javac


6) To check the setup,

enter the following commands and make sure they indicate the location of java and javac as shown in the previous step.


Code Block
languagebash
linenumberstrue
update-alternatives --list java
update-alternatives --list javac

7) Validate

Restart

Test the installation


Code Block
languagebash
java -version
java -version
sudo reboot -f


...

StepAction

1) Updating the OS


Code Block
languagebash
sudo apt-get update


2) Download Maven


Code Block
languagebash
sudo wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /opt/Download
cd /opt/Download


3) Unzip Maven


Code Block
languagebash
sudo tar xvzf apache-maven-3.6.3-bin.tar.gz -C /opt
sudo chown -R root:root /opt/apache-maven-3.6.3


4) Configuring the Maven environment

To make sure that Maven works properly, you need to set a few environment variables, including JAVA_HOME, M3_HOME, MAVEN_HOME, and PATH.

To make this change, create a file named maven.sh in the /etc/profile.d/ directory.



Code Block
languagebash
sudo vi /etc/profile.d/maven.sh


Code Block
languagebash
title/etc/profile.d/maven.sh
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_241current
export M3_HOME=/opt/apache-maven-3.6.3
export MAVEN_HOME=/opt/apache-maven-3.6.3
export PATH=${M3_HOME}/bin:${PATH}


Code Block
languagebash
sudo chmod +x /etc/profile.d/maven.sh


5) Configuring environment variables




Code Block
languagebash
sudo vi /etc/environment


Code Block
languagebash
title/etc/environnement
linenumberstrue
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/jdk1.8.0_241current/bin:/usr/lib/jvm/jdk1.8.0_241current/db/bin:/usr/lib/jvm/jdk1.8.0_241current/jre/bin:/opt/apache-maven-3.6.3/bin"
J2SDKDIR="/usr/lib/jvm/jdk1.8.0_241current"
J2REDIR="/usr/lib/jvm/jdk1.8.0_241current/jre"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_241current"
MAVEN_HOME=/opt/apache-maven-3.6.3


5) Check the installation


Code Block
languagebash
source /etc/profile.d/maven.sh
mvn -version

# Sample answer
Maven home: /opt/apache-maven-3.6.3
Java version: 1.8.0_241, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk1.8.0_241current/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.0.0-1027-azure", arch: "amd64", family: "unix"


...