{"id":387,"date":"2020-02-11T11:53:49","date_gmt":"2020-02-11T11:53:49","guid":{"rendered":"https:\/\/www.javaindia.in\/blog\/?p=387"},"modified":"2020-06-10T12:49:43","modified_gmt":"2020-06-10T12:49:43","slug":"how-use-maven-dependency-management-tool-java","status":"publish","type":"post","link":"https:\/\/www.javaindia.in\/blog\/how-use-maven-dependency-management-tool-java\/","title":{"rendered":"How to Use Maven &#8211; the Dependency Management tool for Java"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Apache Maven is one of the most commonly used tools in <a href=\"https:\/\/www.javaindia.in\/services\/java-web-application-development\" target=\"_blank\" rel=\"noopener\"><strong>Java web development<\/strong><\/a>. It&#8217;s a software project management and comprehension platform built on the concept of a project object model (POM). The software tool can manage a project&#8217;s build, reporting, and documentation from a central code.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Maven has an XML-based streamlined configuration that allows developers to quickly describe and outline a Java-based project. This makes project development faster and more efficient. Besides, Maven supports long-term project development and software testing. The tool also has a declarative configuration and features vast swath plugins that make the programming process much easier. That&#8217;s why every <a href=\"https:\/\/www.javaindia.in\" target=\"_blank\" rel=\"noopener\"><strong>Java development company<\/strong><\/a> uses Maven to speed up their development projects.<\/span><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.javaindia.in\/blog\/how-use-maven-dependency-management-tool-java\/#The_Working_Mechanism_of_Maven\" >The Working Mechanism of Maven<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.javaindia.in\/blog\/how-use-maven-dependency-management-tool-java\/#The_Maven_POM\" >The Maven POM<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.javaindia.in\/blog\/how-use-maven-dependency-management-tool-java\/#The_Maven_Directory\" >The Maven Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.javaindia.in\/blog\/how-use-maven-dependency-management-tool-java\/#Maven_Repositories\" >Maven Repositories<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.javaindia.in\/blog\/how-use-maven-dependency-management-tool-java\/#How_to_Install_Maven\" >How to Install Maven<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.javaindia.in\/blog\/how-use-maven-dependency-management-tool-java\/#How_to_host_your_Java_project_in_a_Maven_repository\" >How to host your Java project in a Maven repository<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"The_Working_Mechanism_of_Maven\"><\/span><span style=\"color: #000000;\">The Working Mechanism of Maven<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Maven dramatically simplifies the complicated configuration associated with Java development. Below are the major components of the Java development tool:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">1) The Project Object Model (POM) that describes a Maven project and its dependencies.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">2) The directory, which is a standardized format for describing a Maven project.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">3) Repositories where third-party software applications are stored.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Now let&#8217;s discuss the functions and roles of these parts elaborately. Understanding the specific roles of every element of this helps you to efficiently use Maven and improve the quality of your development process.<\/span><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"The_Maven_POM\"><\/span><span style=\"color: #000000;\">The Maven POM<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Java development projects based on the Apache Maven platform use a POM file in its root directory. The dependencies of the project are described by pom.xml. This information guides you throughout the development path. Keep in mind that dependencies are third-party software applications used in the development process.<\/span><\/p>\n<blockquote><p><strong><span style=\"color: #000000;\">Interesting Read:<\/span><a href=\"https:\/\/www.javaindia.in\/blog\/top-unit-testing-tools-java-developers-2020\/\" target=\"_blank\" rel=\"noopener\"> Top 5 Unit Testing Tools for Java Developers in 2020<\/a><\/strong><\/p><\/blockquote>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"The_Maven_Directory\"><\/span><span style=\"color: #000000;\">The Maven Directory<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">The directory uses the technique known as convention over configuration. This process smartly solves the problems associated with the complications created by Java configuration. Maven creates a simplified, common project structure and provides a standard file format. By simply using plugins, developers can let describe dependencies and set the project configuration.<\/span><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Maven_Repositories\"><\/span><span style=\"color: #000000;\">Maven Repositories<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">The Maven platform leverages centralized repositories to store, discover, publish project packages in the form of dependencies. Once the developer references a dependency in the project, Maven discovers it the centralized repository. Then the dependency is downloaded to a local repository and installed to the project.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">As mentioned earlier, Maven automatically resolves dependencies from its central repository. However, there&#8217;s an alternative as well. JCenter can be used to access a wide range of packages. Additionally, software companies also host and publish private repositories.<\/span><\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"How_to_Install_Maven\"><\/span><span style=\"color: #000000;\">How to Install Maven<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Before installing Maven, you need to set up the Java Development Kit environment. Once you&#8217;re done with the JDK set up, follow the below-listed steps to install Maven.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">1.Download the latest version of Maven (3.6.3 as of February 2020)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">2. Extract the apache.maven.zip file.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">3.Store the file in your path<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">4. Have access to the mvn command.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">5.Type mvn -v to ensure the installation.<\/span><\/p>\n<blockquote><p><strong><span style=\"color: #000000;\">Interesting Read:<\/span> <a href=\"https:\/\/www.javaindia.in\/blog\/top-10-java-tools-consider-web-app-development\/\" target=\"_blank\" rel=\"noopener\">Top 10 Java Tools To Consider For Innovative Web App Development<\/a><\/strong><\/p><\/blockquote>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"How_to_host_your_Java_project_in_a_Maven_repository\"><\/span><span style=\"color: #000000;\">How to host your Java project in a Maven repository<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">If you want to develop a dependency-based project there are four different ways you can create a library for other projects. You can make it available locally, publish it to a privately-managed remote repository, publish it to a cloud-hosted private repository, or publish it to a public repository like Maven Central.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">The popularity of Maven as a Java development tool has grown exponentially. As the number of businesses choosing their <a href=\"https:\/\/www.javaindia.in\/services\/java-enterprise-application-development\" target=\"_blank\" rel=\"noopener\"><strong>enterprise application in Java<\/strong><\/a>, the role of Maven will grow even further. Whether you are a Java developer or a business owner looking for Java-based solutions, knowing Maven is equally important.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong>FAQs<\/strong><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-390\" src=\"https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions.jpg\" alt=\"frequently asked questions\" width=\"700\" height=\"350\" srcset=\"https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions.jpg 700w, https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions-300x150.jpg 300w, https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions-360x180.jpg 360w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong>Q.1. What does Maven mean?<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Maven is an automation and management tool used in software development. The tool was developed by Apache Software Foundation, was initially released in July 2004. In the Yiddish language, the meaning of Maven is the &#8220;accumulator of knowledge.&#8221;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong>Q.2. What does Java mean?<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Java is a general-purpose programming language developed by Sun Microsystems. It&#8217;s a class-based, object-oriented, language and designed to have as few implementation dependencies as possible. Java programs are multiplatform and can run on different platforms, including Macintosh, Windows, and Unix computers.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong>Q.3. What is the use of Java?<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Java is a widely used coding language expressly designed for the distributed environment of the internet. It is the most popular programming language for Android apps. Java is also among the most preferred language for the development of the Internet of Things (IoT) solutions.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong>Q.4. What is Maven dependency?<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Maven dependency is a library, framework or otherwise JAR file that is stored on a remote server. The file is stored with proper detailed information placed in a Maven POM file. The file can be downloaded and referenced in the next project, either upon compilation, testing, or during runtime.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Maven is one of the most commonly used tools in Java web development. It&#8217;s a software project management and comprehension platform built on the concept of a project object model (POM). The software tool can manage a project&#8217;s build, reporting, and documentation from a central code. Maven has an XML-based streamlined configuration that allows developers to quickly describe and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":389,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[22],"tags":[],"class_list":["post-387","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts\/387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/comments?post=387"}],"version-history":[{"count":11,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts\/387\/revisions"}],"predecessor-version":[{"id":519,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts\/387\/revisions\/519"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/media\/389"}],"wp:attachment":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/media?parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/categories?post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/tags?post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}