How To Install Apache Maven In Ubuntu(Linux)

#JavaInspires

How To Install Apache Maven In Ubuntu(Linux) Java Inspires

 Hi Guys,

Welcome to Java Inspires.

In this post, we will see how to install Apache Maven in Ubuntu Linux.

Here, I have used following commands in the terminal.

sudo apt-get update

$ sudo apt install maven

$ mvn -version


developer@developer:~$ sudo apt-get update
[sudo] password for developer: 
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Hit:3 http://us.archive.ubuntu.com/ubuntu focal InRelease             
Get:4 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [24.4 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [58.3 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [474 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [983 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [263 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [774 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages [572 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [323 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu focal-updates/universe DEP-11 64x64 Icons [362 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:16 http://us.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [1,768 B]
Fetched 4,162 kB in 7s (593 kB/s)                                     
Reading package lists... Done
developer@developer:~$ 
developer@developer:~$ mvn

Command 'mvn' not found, but can be installed with:

sudo apt install maven

developer@developer:~$ sudo apt install maven
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-5.8.0-43-generic linux-hwe-5.8-headers-5.8.0-43
  linux-image-5.8.0-43-generic linux-modules-5.8.0-43-generic
  linux-modules-extra-5.8.0-43-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libaopalliance-java libapache-pom-java libatinject-jsr330-api-java
  libcdi-api-java libcommons-cli-java libcommons-io-java
  libcommons-lang3-java libcommons-parent-java
  libgeronimo-annotation-1.3-spec-java
  libgeronimo-interceptor-3.0-spec-java libguava-java libguice-java
  libhawtjni-runtime-java libjansi-java libjansi-native-java
  libjsr305-java libmaven-parent-java libmaven-resolver-java
  libmaven-shared-utils-java libmaven3-core-java
  libplexus-cipher-java libplexus-classworlds-java
  libplexus-component-annotations-java libplexus-interpolation-java
  libplexus-sec-dispatcher-java libplexus-utils2-java
  libsisu-inject-java libsisu-plexus-java libslf4j-java
  libwagon-file-java libwagon-http-shaded-java
  libwagon-provider-api-java
Suggested packages:
  libaopalliance-java-doc libatinject-jsr330-api-java-doc
  libservlet3.1-java libcommons-io-java-doc libcommons-lang3-java-doc
  libasm-java libcglib-java libjsr305-java-doc
  libmaven-shared-utils-java-doc liblogback-java
  libplexus-cipher-java-doc libplexus-classworlds-java-doc
  libplexus-sec-dispatcher-java-doc libplexus-utils2-java-doc junit4
  testng libcommons-logging-java liblog4j1.2-java
The following NEW packages will be installed:
  libaopalliance-java libapache-pom-java libatinject-jsr330-api-java
  libcdi-api-java libcommons-cli-java libcommons-io-java
  libcommons-lang3-java libcommons-parent-java
  libgeronimo-annotation-1.3-spec-java
  libgeronimo-interceptor-3.0-spec-java libguava-java libguice-java
  libhawtjni-runtime-java libjansi-java libjansi-native-java
  libjsr305-java libmaven-parent-java libmaven-resolver-java
  libmaven-shared-utils-java libmaven3-core-java
  libplexus-cipher-java libplexus-classworlds-java
  libplexus-component-annotations-java libplexus-interpolation-java
  libplexus-sec-dispatcher-java libplexus-utils2-java
  libsisu-inject-java libsisu-plexus-java libslf4j-java
  libwagon-file-java libwagon-http-shaded-java
  libwagon-provider-api-java maven
0 upgraded, 33 newly installed, 0 to remove and 18 not upgraded.
Need to get 9,209 kB of archives.
After this operation, 12.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libapache-pom-java all 18-1 [4,720 B]
Get:2 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libatinject-jsr330-api-java all 1.0+ds1-5 [5,348 B]
Get:3 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libgeronimo-interceptor-3.0-spec-java all 1.0.1-4fakesync [8,616 B]
Get:4 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libcdi-api-java all 1.2-2 [54.5 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libcommons-cli-java all 1.4-1 [53.8 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libcommons-parent-java all 43-1 [10.8 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libcommons-io-java all 2.6-2 [198 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libcommons-lang3-java all 3.8-2 [458 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libgeronimo-annotation-1.3-spec-java all 1.0-1 [10.7 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libjsr305-java all 0.1~+svn49-11 [27.0 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libguava-java all 19.0-1 [2,028 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libaopalliance-java all 20070526-6 [9,084 B]
Get:13 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libguice-java all 4.2.1-1 [962 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libhawtjni-runtime-java all 1.17-1 [28.8 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libjansi-native-java all 1.8-1 [23.8 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libjansi-java all 1.18-1 [56.8 kB]
Get:17 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libmaven-parent-java all 31-2 [5,140 B]
Get:18 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libplexus-utils2-java all 3.3.0-1 [250 kB]
Get:19 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libwagon-provider-api-java all 3.3.4-1 [48.5 kB]
Get:20 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libmaven-resolver-java all 1.4.1-1 [555 kB]
Get:21 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libmaven-shared-utils-java all 3.3.0-1 [149 kB]
Get:22 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libplexus-cipher-java all 1.7-3 [15.1 kB]
Get:23 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libplexus-classworlds-java all 2.6.0-1 [49.4 kB]
Get:24 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libplexus-component-annotations-java all 2.1.0-1 [6,564 B]
Get:25 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libplexus-interpolation-java all 1.26-1 [76.8 kB]
Get:26 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libplexus-sec-dispatcher-java all 1.4-4 [28.1 kB]
Get:27 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libslf4j-java all 1.7.25-3 [141 kB]
Get:28 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libsisu-inject-java all 0.3.3-1 [347 kB]
Get:29 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libsisu-plexus-java all 0.3.3-3 [182 kB]
Get:30 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libmaven3-core-java all 3.6.3-1 [1,535 kB]
Get:31 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libwagon-file-java all 3.3.4-1 [7,928 B]
Get:32 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libwagon-http-shaded-java all 3.3.4-1 [1,855 kB]
Get:33 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 maven all 3.6.3-1 [17.8 kB]
Fetched 9,209 kB in 23s (395 kB/s)                                    
Extracting templates from packages: 100%
Selecting previously unselected package libapache-pom-java.
(Reading database ... 228033 files and directories currently installed.
)
Preparing to unpack .../00-libapache-pom-java_18-1_all.deb ...
Unpacking libapache-pom-java (18-1) ...
Selecting previously unselected package libatinject-jsr330-api-java.
Preparing to unpack .../01-libatinject-jsr330-api-java_1.0+ds1-5_all.de
b ...
Unpacking libatinject-jsr330-api-java (1.0+ds1-5) ...
Selecting previously unselected package libgeronimo-interceptor-3.0-spe
c-java.
Preparing to unpack .../02-libgeronimo-interceptor-3.0-spec-java_1.0.1-
4fakesync_all.deb ...
Unpacking libgeronimo-interceptor-3.0-spec-java (1.0.1-4fakesync) ...
Selecting previously unselected package libcdi-api-java.
Preparing to unpack .../03-libcdi-api-java_1.2-2_all.deb ...
Unpacking libcdi-api-java (1.2-2) ...
Selecting previously unselected package libcommons-cli-java.
Preparing to unpack .../04-libcommons-cli-java_1.4-1_all.deb ...
Unpacking libcommons-cli-java (1.4-1) ...
Selecting previously unselected package libcommons-parent-java.
Preparing to unpack .../05-libcommons-parent-java_43-1_all.deb ...
Unpacking libcommons-parent-java (43-1) ...
Selecting previously unselected package libcommons-io-java.
Preparing to unpack .../06-libcommons-io-java_2.6-2_all.deb ...
Unpacking libcommons-io-java (2.6-2) ...
Selecting previously unselected package libcommons-lang3-java.
Preparing to unpack .../07-libcommons-lang3-java_3.8-2_all.deb ...
Unpacking libcommons-lang3-java (3.8-2) ...
Selecting previously unselected package libgeronimo-annotation-1.3-spec
-java.
Preparing to unpack .../08-libgeronimo-annotation-1.3-spec-java_1.0-1_a
ll.deb ...
Unpacking libgeronimo-annotation-1.3-spec-java (1.0-1) ...
Selecting previously unselected package libjsr305-java.
Preparing to unpack .../09-libjsr305-java_0.1~+svn49-11_all.deb ...
Unpacking libjsr305-java (0.1~+svn49-11) ...
Selecting previously unselected package libguava-java.
Preparing to unpack .../10-libguava-java_19.0-1_all.deb ...
Unpacking libguava-java (19.0-1) ...
Selecting previously unselected package libaopalliance-java.
Preparing to unpack .../11-libaopalliance-java_20070526-6_all.deb ...
Unpacking libaopalliance-java (20070526-6) ...
Selecting previously unselected package libguice-java.
Preparing to unpack .../12-libguice-java_4.2.1-1_all.deb ...
Unpacking libguice-java (4.2.1-1) ...
Selecting previously unselected package libhawtjni-runtime-java.
Preparing to unpack .../13-libhawtjni-runtime-java_1.17-1_all.deb ...
Unpacking libhawtjni-runtime-java (1.17-1) ...
Selecting previously unselected package libjansi-native-java.
Preparing to unpack .../14-libjansi-native-java_1.8-1_all.deb ...
Unpacking libjansi-native-java (1.8-1) ...
Selecting previously unselected package libjansi-java.
Preparing to unpack .../15-libjansi-java_1.18-1_all.deb ...
Unpacking libjansi-java (1.18-1) ...
Selecting previously unselected package libmaven-parent-java.
Preparing to unpack .../16-libmaven-parent-java_31-2_all.deb ...
Unpacking libmaven-parent-java (31-2) ...
Selecting previously unselected package libplexus-utils2-java.
Preparing to unpack .../17-libplexus-utils2-java_3.3.0-1_all.deb ...
Unpacking libplexus-utils2-java (3.3.0-1) ...
Selecting previously unselected package libwagon-provider-api-java.
Preparing to unpack .../18-libwagon-provider-api-java_3.3.4-1_all.deb .
..
Unpacking libwagon-provider-api-java (3.3.4-1) ...
Selecting previously unselected package libmaven-resolver-java.
Preparing to unpack .../19-libmaven-resolver-java_1.4.1-1_all.deb ...
Unpacking libmaven-resolver-java (1.4.1-1) ...
Selecting previously unselected package libmaven-shared-utils-java.
Preparing to unpack .../20-libmaven-shared-utils-java_3.3.0-1_all.deb .
..
Unpacking libmaven-shared-utils-java (3.3.0-1) ...
Selecting previously unselected package libplexus-cipher-java.
Preparing to unpack .../21-libplexus-cipher-java_1.7-3_all.deb ...
Unpacking libplexus-cipher-java (1.7-3) ...
Selecting previously unselected package libplexus-classworlds-java.
Preparing to unpack .../22-libplexus-classworlds-java_2.6.0-1_all.deb .
..
Unpacking libplexus-classworlds-java (2.6.0-1) ...
Selecting previously unselected package libplexus-component-annotations
-java.
Preparing to unpack .../23-libplexus-component-annotations-java_2.1.0-1
_all.deb ...
Unpacking libplexus-component-annotations-java (2.1.0-1) ...
Selecting previously unselected package libplexus-interpolation-java.
Preparing to unpack .../24-libplexus-interpolation-java_1.26-1_all.deb 
...
Unpacking libplexus-interpolation-java (1.26-1) ...
Selecting previously unselected package libplexus-sec-dispatcher-java.
Preparing to unpack .../25-libplexus-sec-dispatcher-java_1.4-4_all.deb 
...
Unpacking libplexus-sec-dispatcher-java (1.4-4) ...
Selecting previously unselected package libslf4j-java.
Preparing to unpack .../26-libslf4j-java_1.7.25-3_all.deb ...
Unpacking libslf4j-java (1.7.25-3) ...
Selecting previously unselected package libsisu-inject-java.
Preparing to unpack .../27-libsisu-inject-java_0.3.3-1_all.deb ...
Unpacking libsisu-inject-java (0.3.3-1) ...
Selecting previously unselected package libsisu-plexus-java.
Preparing to unpack .../28-libsisu-plexus-java_0.3.3-3_all.deb ...
Unpacking libsisu-plexus-java (0.3.3-3) ...
Selecting previously unselected package libmaven3-core-java.
Preparing to unpack .../29-libmaven3-core-java_3.6.3-1_all.deb ...
Unpacking libmaven3-core-java (3.6.3-1) ...
Selecting previously unselected package libwagon-file-java.
Preparing to unpack .../30-libwagon-file-java_3.3.4-1_all.deb ...
Unpacking libwagon-file-java (3.3.4-1) ...
Selecting previously unselected package libwagon-http-shaded-java.
Preparing to unpack .../31-libwagon-http-shaded-java_3.3.4-1_all.deb ..
.
Unpacking libwagon-http-shaded-java (3.3.4-1) ...
Selecting previously unselected package maven.
Preparing to unpack .../32-maven_3.6.3-1_all.deb ...
Unpacking maven (3.6.3-1) ...
Setting up libslf4j-java (1.7.25-3) ...
Setting up libplexus-utils2-java (3.3.0-1) ...
Setting up libplexus-classworlds-java (2.6.0-1) ...
Setting up libjsr305-java (0.1~+svn49-11) ...
Setting up libaopalliance-java (20070526-6) ...
Setting up libcommons-cli-java (1.4-1) ...
Setting up libplexus-component-annotations-java (2.1.0-1) ...
Setting up libplexus-cipher-java (1.7-3) ...
Setting up libgeronimo-annotation-1.3-spec-java (1.0-1) ...
Setting up libgeronimo-interceptor-3.0-spec-java (1.0.1-4fakesync) ...
Setting up libapache-pom-java (18-1) ...
Setting up libatinject-jsr330-api-java (1.0+ds1-5) ...
Setting up libplexus-interpolation-java (1.26-1) ...
Setting up libplexus-sec-dispatcher-java (1.4-4) ...
Setting up libwagon-http-shaded-java (3.3.4-1) ...
Setting up libcdi-api-java (1.2-2) ...
Setting up libhawtjni-runtime-java (1.17-1) ...
Setting up libwagon-provider-api-java (3.3.4-1) ...
Setting up libmaven-parent-java (31-2) ...
Setting up libcommons-parent-java (43-1) ...
Setting up libmaven-resolver-java (1.4.1-1) ...
Setting up libguava-java (19.0-1) ...
Setting up libcommons-lang3-java (3.8-2) ...
Setting up libjansi-native-java (1.8-1) ...
Setting up libwagon-file-java (3.3.4-1) ...
Setting up libcommons-io-java (2.6-2) ...
Setting up libguice-java (4.2.1-1) ...
Setting up libjansi-java (1.18-1) ...
Setting up libmaven-shared-utils-java (3.3.0-1) ...
Setting up libsisu-inject-java (0.3.3-1) ...
Setting up libsisu-plexus-java (0.3.3-3) ...
Setting up libmaven3-core-java (3.6.3-1) ...
Setting up maven (3.6.3-1) ...
update-alternatives: using /usr/share/maven/bin/mvn to provide /usr/bin
/mvn (mvn) in auto mode
developer@developer:~$ 


developer@developer:~$ mvn
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.102 s
[INFO] Finished at: 2021-05-14T04:55:20-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
developer@developer:~$ 
developer@developer:~$ mvn -version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.8.0-53-generic", arch: "amd64", family: "unix"
developer@developer:~$

THANK YOU


Post a Comment

Previous Post Next Post