{"id":6725,"date":"2021-06-09T17:58:26","date_gmt":"2021-06-09T17:58:26","guid":{"rendered":"https:\/\/linuxways.net\/?p=6725"},"modified":"2021-06-09T17:58:26","modified_gmt":"2021-06-09T17:58:26","slug":"how-to-install-gradle-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-gradle-on-ubuntu-20-04\/","title":{"rendered":"How to Install Gradle on Ubuntu 20.04"},"content":{"rendered":"<p>Gradle is an open-source automation tool for building applications. It supports various languages including Java, Android, C\/C++, and JavaScript. It is preferred by millions of developers due to its ability to automate the creation of applications which involves compiling, testing, deploying, and publishing applications.<\/p>\n<p>In an earlier post, we described the <a href=\"https:\/\/linuxways.net\/de\/centos\/how-to-install-gradle-on-centos-8\/\">installation of Gradle on CentOS<\/a>. This post explains how to install Gradle on Ubuntu.<\/p>\n<p><strong>Note<\/strong>: We will be demonstrating the procedure on <strong>Ubuntu 20.04 LTS (Focal Fossa) <\/strong>machine<strong>.<\/strong><\/p>\n<h2>Prerequisites<\/h2>\n<p>For Gradle, you must have Java JDK or JRE version 8 or above installed on your Ubuntu machine. To verify if Java is running, use the command below:<\/p>\n<pre>$ java -version<\/pre>\n<p>An output similar to the following will indicate that Java is installed on your machine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"934\" height=\"95\" class=\"wp-image-6726\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-21.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-21.png 934w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-21-300x31.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-21-768x78.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/p>\n<p>To install Gradle on Ubuntu, there are following three methods:<\/p>\n<ul>\n<li>Installation via Direct Download<\/li>\n<li>Installation via Snap<\/li>\n<li>Installation via Apt<\/li>\n<\/ul>\n<h2>Installation via Direct Download<\/h2>\n<p>In the following method, we will install Gradle by downloading the zip package available at Gradle official website. Using this installation method, you can get the latest version of Gradle. The complete steps for the installation of Gradle via Direct Download are as follows:<\/p>\n<p>1. To download Gradle&#8217;s latest version, visit the <a href=\"https:\/\/gradle.org\/releases\/\">Releases<\/a> page and download the binary package. As of May 2021, the latest version of Gradle available on the official Releases page is 7.0.2. So here, we are going to download the Gradle version 7.0.2. You can download it from the Releases page or use the following command to download it from the command line:<\/p>\n<pre>$ wget https:\/\/downloads.gradle-dn.com\/distributions\/gradle-7.0.2-bin.zip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1064\" height=\"283\" class=\"wp-image-6727\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-22.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-22.png 1064w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-22-300x80.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-22-1024x272.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-22-768x204.png 768w\" sizes=\"auto, (max-width: 1064px) 100vw, 1064px\" \/><\/p>\n<p>2. The downloaded file is in zip format, you will need to extract it. Use the command below to unzip it in <strong>\/opt\/gradle<\/strong> directory.<\/p>\n<pre>$ sudo unzip -d \/opt\/gradle<\/pre>\n<p>To verify if the file has been extracted, use the command below:<\/p>\n<pre>$ ls \/opt\/gradle\/gradle-7.0.2<\/pre>\n<p>You should see the following content in your output:<\/p>\n<p><em><img loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"49\" class=\"wp-image-6728\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-23.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-23.png 470w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-23-300x31.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/em><\/p>\n<p>3. Now, you will need to setup the environment variable. You can do this by creating a new file inside the <strong>\/etc\/profile.d<\/strong> directory:<\/p>\n<pre>$ sudo nano \/etc\/profile.d\/gradle.sh<\/pre>\n<p>Add the following lines in the file:<\/p>\n<pre>export GRADLE_HOME=\/opt\/gradle\/gradle-7.0.2<\/pre>\n<pre>export PATH=${GRADLE_HOME}\/bin:${PATH}<\/pre>\n<p>Then save and close the file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"569\" height=\"108\" class=\"wp-image-6729\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-24.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-24.png 569w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-24-300x57.png 300w\" sizes=\"auto, (max-width: 569px) 100vw, 569px\" \/><\/p>\n<p>4. Then give the <strong>\/etc\/profile.d\/gradle.sh<\/strong> file execute permission using the command below:<\/p>\n<pre>$ sudo chmod +x \/etc\/profile.d\/gradle.sh<\/pre>\n<p>5. Now load the environment variables as follows:<\/p>\n<pre>$ source \/etc\/profile.d\/gradle.sh<\/pre>\n<p>6. To verify the installation of Gradle and to view the version installed, use the command below:<\/p>\n<pre>$ gradle -v<\/pre>\n<p>The following output indicates Gradle version 7.0.2 has been installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"809\" height=\"577\" class=\"wp-image-6730\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-25.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-25.png 809w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-25-300x214.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-25-768x548.png 768w\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" \/><\/p>\n<h2>Installation via Snap<\/h2>\n<p>The snap package for Gradle is also available for installation on Ubuntu. This method also installs the latest version of Gradle on your system.<\/p>\n<p>The complete steps are as follows:<\/p>\n<p>1. If snapd is not installed already on your system, you can install it as follows:<\/p>\n<pre>$ sudo apt update<\/pre>\n<pre>$ sudo apt install snapd<\/pre>\n<p>2. Then install Gradle snap using the command below:<\/p>\n<pre>$ sudo snap install gradle --classic<\/pre>\n<p>The following output indicates Gradle version 7.0.2 has been installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"580\" height=\"51\" class=\"wp-image-6731\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-26.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-26.png 580w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-26-300x26.png 300w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<p>Or you can use the following command to view detailed information:<\/p>\n<pre>$ \/snap\/bin\/gradle -v<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"751\" height=\"365\" class=\"wp-image-6732\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-27.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-27.png 751w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-27-300x146.png 300w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/p>\n<h2>Installation via Apt<\/h2>\n<p>Another method to install Gradle is via apt. However, this method does not install the latest version of Gradle. The complete steps for the installation of Gradle via apt are as follows:<\/p>\n<p>1. Update the repository index using this command:<\/p>\n<pre>$ sudo apt update<\/pre>\n<p>5. Now to install Gradle on your system, use the command below:<\/p>\n<pre>$ sudo apt install gradle -y<\/pre>\n<p>This command will install Gradle on your system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"233\" class=\"wp-image-6733\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-28.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-28.png 780w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-28-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-28-768x229.png 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/p>\n<p>6. To verify the installation of Gradle and to view the version installed, use the command below:<\/p>\n<pre>$ gradle -v<\/pre>\n<p>The following output indicates Gradle version 4.4.1 has been installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"306\" class=\"wp-image-6734\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-29.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-29.png 790w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-29-300x116.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-29-768x297.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/p>\n<h2>Uninstall Gradle<\/h2>\n<p>If you want to remove Gradle from your system, you can do so using the following methods:<\/p>\n<p>If you have installed Gradle using the direct download method, you can uninstall it as follows:<\/p>\n<pre>$ sudo rm gradle-7.0.2-bin.zip<\/pre>\n<pre>$ sudo rm -r \/opt\/gradle \/gradle.sh<\/pre>\n<pre>$ sudo rm -r \/usr\/lib\/gradle\/<\/pre>\n<p>To remove Gradle installed via snap, use the command below to remove it:<\/p>\n<pre>$ sudo snap remove gradle<\/pre>\n<p>To remove Gradle installed via apt, use the command below to remove it:<\/p>\n<pre>$ sudo apt remove gradle<\/pre>\n<p>In this post, we described the installation of Gradle on the Ubuntu system using three different ways. We described step by step procedure for each of the installation procedures. In the end, we also described how to uninstall Gradle if you ever have to do that.<\/p>","protected":false},"excerpt":{"rendered":"<p>Gradle is an open-source automation tool for building applications. It supports various languages including Java, Android, C\/C++, and JavaScript. It is preferred by millions of developers due to&hellip;<\/p>","protected":false},"author":1,"featured_media":7112,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[244,100],"class_list":["post-6725","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-gradle","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=6725"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6725\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/7112"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=6725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=6725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=6725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}