-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy path004. Maven and Java on Ubuntu VM.txt
63 lines (45 loc) · 1.29 KB
/
004. Maven and Java on Ubuntu VM.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Installation and Configuration of Maven and Java on Ubuntu EC2 instance
======================================================================================================
Step1:
**********
Update the packages
sudo apt update -y
sudo apt upgrade -y
Step2:
**********
Install Java
Install OpenJDK 11 (or another version if you prefer):
sudo apt install openjdk-11-jdk -y
Verify the installation:
java -version
Step3:
**********
Install Maven
Install Maven using the default package manager:
sudo apt install maven -y
Verify the installation:
mvn -version
Step4:
**********
Configure Environment Variables
Open the environment profile file:
sudo nano /etc/profile.d/maven.sh
Add the following lines to configure JAVA_HOME, MAVEN_HOME, and update the PATH:
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export MAVEN_HOME=/usr/share/maven
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
Save and close the file
Step5:
*********
Apply the Environment Variables
Load the new environment variables into the current session:
source /etc/profile.d/maven.sh
Step6:
*********
Verify the Installation
Verify the Java installation:
echo $JAVA_HOME
java -version
Verify the Maven installation:
echo $MAVEN_HOME
mvn -version