To install Gradle 7 on Ubuntu with Java 1.8 already installed
-
Open a terminal window.
-
Update the package list:
sudo apt update
-
Install wget if it's not already installed:
sudo apt install wget
-
Download Gradle 7.6.2 (the latest version in the 7.x series):
wget https://services.gradle.org/distributions/gradle-7.6.2-bin.zip
-
Create a directory for Gradle:
sudo mkdir /opt/gradle
-
Extract the downloaded zip file to the new directory:
sudo unzip -d /opt/gradle gradle-7.6.2-bin.zip
-
Set up environment variables by editing the profile file:
sudo nano /etc/profile.d/gradle.sh
-
Add the following lines to the file:
export GRADLE_HOME=/opt/gradle/gradle-7.6.2 export PATH=${GRADLE_HOME}/bin:${PATH}
-
Save and exit the file (Ctrl+X, then Y, then Enter).
-
Make the script executable:
sudo chmod +x /etc/profile.d/gradle.sh
-
Load the environment variables:
source /etc/profile.d/gradle.sh
-
Verify the installation:
gradle --version