{"id":9764,"date":"2021-08-06T23:02:17","date_gmt":"2021-08-06T20:02:17","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9764"},"modified":"2024-03-18T18:57:45","modified_gmt":"2024-03-18T15:57:45","slug":"install-apache-maven-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-apache-maven-on-rocky-linux-8\/","title":{"rendered":"Install Apache Maven on Rocky Linux 8"},"content":{"rendered":"\n<p>In this tutorial, you will learn how to install Apache Maven on Rocky Linux 8. <a href=\"https:\/\/maven.apache.org\/what-is-maven.html\" target=\"_blank\" rel=\"noreferrer noopener\">Apache Maven<\/a> is <em>a Java project management and project comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project&#8217;s build, reporting and documentation from a central piece of information<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Apache Maven on Rocky Linux 8<\/h2>\n\n\n\n<p>There are three ways in which you can install Apache Maven.<\/p>\n\n\n\n<ol class=\"wp-block-list\" id=\"ready-made-binary\">\n<li><a href=\"#install-from-repo\">Install from the default Rocky Linux AppStream  Repository<\/a><\/li>\n\n\n\n<li><a href=\"#ready-made-binary\">Install latest release version of Maven using ready-made binary<\/a><\/li>\n\n\n\n<li>Build Maven from the source code (Beyond the scope of this tutorial)<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-from-repo\">Install Apache Maven from Repository<\/h3>\n\n\n\n<p>Maven is available on the default Rocky Linux 8 AppStream repositories.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf info maven<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Available Packages\nName         : maven\nEpoch        : 1\nVersion      : 3.5.4\nRelease      : 5.module+el8.3.0+133+b8b54b58\nArchitecture : noarch\nSize         : 26 k\nSource       : maven-3.5.4-5.module+el8.3.0+133+b8b54b58.src.rpm\nRepository   : appstream\nSummary      : Java project management and project comprehension tool\nURL          : http:\/\/maven.apache.org\/\nLicense      : ASL 2.0 and MIT<\/code><\/pre>\n\n\n\n<p>The Maven packages provided by the AppStream repos may not be up-to-date. See for example, the current stable Maven releases version is Maven 3.8.1 as per the <a href=\"https:\/\/maven.apache.org\/docs\/history.html\" target=\"_blank\" rel=\"noreferrer noopener\">Maven release page<\/a>.<\/p>\n\n\n\n<p>If you however want to install this version, then you can run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install maven -y<\/code><\/pre>\n\n\n\n<p>Once the installation is done, you check the version;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mvn --version<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Apache Maven 3.5.4 (Red Hat 3.5.4-5)\nMaven home: \/usr\/share\/maven\nJava version: 11.0.12, vendor: Red Hat, Inc., runtime: \/usr\/lib\/jvm\/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64\nDefault locale: en_US, platform encoding: UTF-8\nOS name: \"linux\", version: \"4.18.0-305.10.2.el8_4.x86_64\", arch: \"amd64\", family: \"unix\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ready-made-binary\">Install latest release version of Maven using ready-made binary<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Install OpenJDK on Rocky Linux 8<\/h4>\n\n\n\n<p>If you want to install the latest release version of Maven using the ready-made binary, then you have to ensure OpenJDK 1.7++ is installed.<\/p>\n\n\n\n<p>In this demo, we are going to use OpenJDK 11, which is the latest version provided by the AppStream repo as of this writing.<\/p>\n\n\n\n<p>OpenJDK 11 can be installed on Rocky Linux 8 by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install java-11-openjdk<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Apache Maven<\/h4>\n\n\n\n<p>Once OpenJDK is in place, you can download the binary from the <a href=\"https:\/\/maven.apache.org\/download.cgi#files\" target=\"_blank\" rel=\"noreferrer noopener\">downloads page<\/a>.<\/p>\n\n\n\n<p>Current version is v3.8.1. Hence, get the download link to the latest version and pull it. To download v3.8.1, then run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/downloads.apache.org\/maven\/maven-3\/3.8.1\/binaries\/apache-maven-3.8.1-bin.tar.gz<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Extract the Maven Tarball <\/h4>\n\n\n\n<p>You can extract it to \/opt or any other directory of your preference, since you will have to add the Maven binary directory to the current PATH.<\/p>\n\n\n\n<p>We use <strong><code>\/usr\/local\/maven<\/code><\/strong> in this demo.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkdir \/usr\/local\/maven<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar xzf apache-maven-3.8.1-bin.tar.gz -C \/usr\/local\/maven\/ --strip-components=1<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add the bin directory to your PATH<\/h4>\n\n\n\n<p>Update the PATH with the path to Maven binaries;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo export 'PATH=$PATH:\/usr\/local\/maven\/bin\/' &gt; \/etc\/profile.d\/maven.sh<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chmod +x \/etc\/profile.d\/maven.sh<\/code><\/pre>\n\n\n\n<p>Update also the path to JAVA_HOME;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo 'export JAVA_HOME=\/usr\/lib\/jvm\/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64' &gt;&gt; \/etc\/profile.d\/maven.sh<\/code><\/pre>\n\n\n\n<p>Source the variables path;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>source \/etc\/profile.d\/maven.sh<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Verify that it is correctly installed<\/h4>\n\n\n\n<p>You can verify that Maven is installed correctly;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mvn --version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)\nMaven home: \/usr\/local\/maven\nJava version: 11.0.12, vendor: Red Hat, Inc., runtime: \/usr\/lib\/jvm\/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64\nDefault locale: en_US, platform encoding: UTF-8\nOS name: \"linux\", version: \"4.18.0-305.10.2.el8_4.x86_64\", arch: \"amd64\", family: \"unix\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Getting Started with Apache Maven<\/h3>\n\n\n\n<p>You can now learn on how to use Maven on the getting started page, link provided below;<\/p>\n\n\n\n<p><a href=\"https:\/\/maven.apache.org\/guides\/getting-started\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">Maven Getting Started Guide<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Other Tutorials<\/h2>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-latest-nodejs-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Latest Nodejs on Rocky Linux 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-yarn-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Yarn on Rocky Linux 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-python-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Python on Rocky Linux 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to install Apache Maven on Rocky Linux 8. Apache Maven is a Java project management and project comprehension<\/p>\n","protected":false},"author":1,"featured_media":9982,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121],"tags":[3930,3928,3931,3932,3929,3933,3587],"class_list":["post-9764","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-apache-maven","tag-install-apache-maven-on-rocky-linux-8","tag-install-maven-rock-linux","tag-maven","tag-maven-rocky-linux-8","tag-mvn","tag-rocky-linux-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9764"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=9764"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9764\/revisions"}],"predecessor-version":[{"id":21702,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9764\/revisions\/21702"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9982"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=9764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=9764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=9764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}