Gradle command not found - Ubuntu
How to Install Gradle Command on Ubuntu
Gradle is a powerful build automation tool that is used primarily for Java projects. If you encounter the “gradle: command not found” error on your Ubuntu system, you will need to install Gradle to resolve this issue.
Step 1: Check Java Installation
Before installing Gradle, make sure you have Java installed on your system. You can check this by running the following command:
java -version
If Java is not installed, you can install it using:
sudo apt update
sudo apt install default-jdk
Step 2: Download and Extract Gradle
- Go to the Gradle downloads page and copy the link to the latest version of Gradle.
- Run the following commands to download and extract Gradle (replace
<GRADLE_VERSION>
with the version you copied):
sudo mkdir /opt/gradle
cd /opt/gradle
sudo wget <GRADLE_DOWNLOAD_URL>
sudo tar -zxvf gradle-<GRADLE_VERSION>.zip
Step 3: Set Gradle Environment Variables
- Open the
.profile
file in a text editor:
sudo nano ~/.profile
- Add the following lines at the end of the file (replace
<GRADLE_VERSION>
with the version you downloaded):
export GRADLE_HOME=/opt/gradle/gradle-<GRADLE_VERSION>
export PATH=$PATH:$GRADLE_HOME/bin
- Save and close the file, then apply the changes by running:
source ~/.profile
Step 4: Verify Installation
To verify that Gradle has been installed successfully, run:
gradle -v
You should see the Gradle version and other information displayed.
Troubleshooting
If you encounter any issues with the installation process, make sure to check for any error messages and refer to the official Gradle documentation for troubleshooting tips.
Conclusion
By following these steps, you should now have Gradle installed on your Ubuntu system and be able to use the gradle
command for building and managing your Java projects efficiently.