🐧 Linux/WSL (Ubuntu)Public
Setting up your local development environment for Java on Linux/WSL (Ubuntu).
Warning
- This guide is for local setup. If you are working on CSE, you do not need to follow this.
- It is recommended to setup development locally in-case you need to use it.
- It is highly recommended to use WSL2 instead of WSL1.
Tip
This guide is for the Ubuntu distro. Other distro's will follow very similar steps which you can look up.
1. Installing Java JDK 17 On Your Machine
Warning
It is important that you install exactly Java JDK version 17.x on your machine.
This is how we will be compiling and testing your code.
To install the JDK:
- Run
sudo apt update
- Run
sudo apt install openjdk-17-jdk -y
- Verify installation using the command:
The output should look like the following (doesn't need to be identical. Most importantly needs to show Java 17)
If you get a different major version number, despite installing Java 17, you may need to configure your system to default to Java 17.
For example, for the output below, 2
should be entered to choose java-17-openjdk
.
2. Gradle 8.8 Installation
Note
It is important you install exactly Gradle 8.8.
- Download the Gradle zip file by running:
This will download the file into whatever directory you're currently in.
You can pick any directory you want, but if you are unsure, navigate to your Downloads directory using the command:
cd ~/Downloads
If you are getting an error of "no such directory found", you can create the Downloads directory by using the command:
mkdir -p ~/Downloads
then running thecd ~/Downloads
command again.
Alternatively, you can navigate to this link to download it via a browser here.
- Check the zip file is in your current directory.
A file called gradle-8.8-bin.zip
should exist in the output.
- Run
sudo mkdir -p /opt/gradle
. - Run
sudo unzip -d /opt/gradle gradle-8.8-bin.zip
If you don't have
unzip
. You can install it viasudo apt install unzip
.This command is also assuming that you're in the directory where the
gradle-8.8-bin.zip
file exists.
- Check Gradle was successfully unzipped by running
ls /opt/gradle/gradle-8.8
.
The following output should be expected:
- Now we need to add this Gradle installation to our path so we can use it in our terminal:
This command assumes that you are using the
bash
shell. If you are usingzsh
, replace~/.bashrc
with~/.zshrc
. For other shells, you will have to look this up yourself.
- Reload your terminal configuration by running
source ~/.bashrc
. This will apply any changes made to the~/.bashrc
file in step 6. - Verify installation by running
gradle --version
The following output is expected:
The most important things to note are Gradle 8.8
and JMV: 17.x.y
.
Last updated on