Sunday, March 15, 2026

Configuring Java and Maven

 

1️⃣ Configure Java Environment

Open the Java environment file.

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

Add these lines inside the file:

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

Save and exit:

ESC → :wq → ENTER

Load the configuration:

source /etc/profile.d/java.sh

Verify Java:

java -version

2️⃣ Configure Maven Environment

Open the Maven environment file.

sudo vi /etc/profile.d/maven.sh

Add these lines:

export M2_HOME=/opt/Maven/apache-maven-3.9
export PATH=${M2_HOME}/bin:${PATH}

Save and exit:

ESC → :wq → ENTER

Load the configuration:

source /etc/profile.d/maven.sh

3️⃣ Verify Maven Installation

Run:

mvn -version

Example output:

Apache Maven 3.9.x
Maven home: /opt/Maven/apache-maven-3.9
Java version: 21
OS: Linux

Configuring Java and Maven

  1️⃣ Configure Java Environment Open the Java environment file. sudo vi /etc/profile.d/java.sh Add these lines inside the file: expor...