In addition to the exercism CLI and your favorite text editor, practicing with Exercism exercises in Java requires:
- the Java Development Kit (JDK) — which includes both a Java Runtime and development tools (most notably, the Java compiler); and
- Gradle — a build tool specifically for Java projects.
Choose your operating system:
... or ...
- if you prefer to not use a package manager, you can install manually.
Optionally, you can also use a Java IDE.
Open an administrative command prompt. (If you need assistance opening an administrative prompt, see open an elevated prompt in Windows 8+ (or Windows 7)).
-
If you have not installed Chocolatey, do so now:
C:\Windows\system32> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
-
Install the JDK:
C:\Windows\system32> choco install temurin21 ... C:\Windows\system32> refreshenv ...
-
Install Gradle:
C:\Windows\system32>choco install gradle ...
We recommend closing the administrative command prompt and opening a new command prompt. You do not require administrator privileges to practice Exercism exercises.
You now are ready to get started with the Java track of Exercism!
To get started, see "Running the Tests".
Below are instructions for install using the most common method - using Homebrew. If you'd rather, you can also install on macOS without Homebrew.
-
If you haven't installed Homebrew, yet, do so now:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -
Tap the Homebrew Cask — this allows us to install a specific JDK version.
brew tap homebrew/cask-versions
-
Install the JDK:
brew install --cask temurin21
-
Install Gradle:
brew install gradle
You now are ready to get started with the Java track of Exercism!
To get started, see "Running the Tests".
Below are instructions for install using the package manager of your distro. If you'd rather, you can also install on Linux without a package manager.
If you are using Debian or its derivatives (like Ubuntu), use APT.
These steps have been verified on Ubuntu 20.04 and 22.04
-
Install the JDK:
sudo apt-get update sudo apt-get install software-properties-common sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-21-jdk
-
Install Gradle:
sudo add-apt-repository ppa:cwchien/gradle sudo apt-get update sudo apt-get install gradle
You now are ready to get started with the Java track of Exercism!
To get started, see "Running the Tests".
There are a lot of ways to install JDK 21, but one of the easiest ways is to use SDKMAN, which lets you install both OpenJDK 21 and the latest Gradle with ease.
Use the following steps:
-
Install SDKMAN:
curl -s "https://get.sdkman.io" | bash
(if that doesn't work, take a look at the installation instructions)
-
Install OpenJDK 21:
sdk install java 21.0.1-tem
-
Install Gradle:
sdk install gradle
You now are ready to get started with the Java track of Exercism!
To get started, see "Running the Tests".
- Installing on Windows manually
- Installing on macOS without Homebrew
- Installing on Linux without a package manager
These instructions are intended for experienced Windows users.
If you don't already know how to set environment variables or feel comfortable managing the directory structure, we highly recommend you use the Chocolatey-based install, [above](#windows).
- Install the JDK:
- Download "OpenJDK 21 (LTS)" from Adoptium (choose ".msi").
- Run the installer, using all the defaults.
- Install Gradle:
- Download "Binary only distribution" from the Gradle download page.
- Unzip the archive. We recommend a place like
C:\Users\JohnDoe\Tools. - Add a new system environment variable named
GRADLE_HOMEand set it to the path you just created (e.g.C:\Users\JohnDoe\Tools\gradle-x.y). - Update the system
Pathto include thebindirectory from Gradle's home (e.g.Path=...;%GRADLE_HOME%\bin).
You now are ready to get started with the Java track of Exercism!
To get started, see "Running the Tests".
These instructions are intended for experienced macOS users.
Unless you specifically do not want to use a package manager, we highly recommend using the Homebrew-based installation instructions, [above](#macos).
-
Install the JDK:
- Download "OpenJDK 21 (LTS)" from Adoptium (choose ".pkg").
- Run the installer, using all the defaults.
-
Install Gradle:
-
Download "Binary only distribution" from the Gradle download page.
-
Unpack Gradle:
mkdir ~/tools cd ~/tools unzip ~/Downloads/gradle-*-bin.zip cd gradle*
-
Configure Gradle and add it to the path:
cat << DONE >> ~/.bashrc export GRADLE_HOME=`pwd` export PATH=\$PATH:\$GRADLE_HOME/bin DONE
-
You now are ready to get started with the Java track of Exercism!
To get started, see "Running the Tests".
These instructions are intended for experienced Linux users.
Unless you specifically do not want to use a package manager, we highly recommend using the installation instructions, [above](#linux).
-
Install the JDK:
- Choose your distribution and download "OpenJDK 21 (LTS)" from Adoptium (choose ".tar.gz").
- Run the installer, using all the defaults.
-
Install Gradle:
-
Download "Binary only distribution" from the Gradle download page.
-
Unpack Gradle:
mkdir ~/tools cd ~/tools unzip ~/Downloads/gradle-*-bin.zip cd gradle*
-
Configure Gradle and add it to the path:
cat << DONE >> ~/.bashrc export GRADLE_HOME=`pwd` export PATH=\$PATH:\$GRADLE_HOME/bin DONE
-
You now are ready to get started with the Java track of Exercism!
To get started, see "Running the Tests".
There are many Java IDEs available. The three most popular are:
- IntelliJ IDEA (download the "Community" edition)
- Eclipse
- NetBeans (download the "Java SE" bundle)
and there are others.