How to Setup Environment Variables for Java & Gradle
- Péter Földházi Jr.
- Mar 8
- 1 min read
I originally created this article to help my students who attend my Java Test Automation workshops but of course anyone is welcome to learn from it. :-)
If you wish to start doing development work in Java using Gradle, you will need to ensure that both of them are configured properly after installation. For that, you need to set up an environment variable for both Java and Gradle, otherwise your OS (Operating System) and IDE (integrated development) won't recognize them, or not the correct version, which will lead to numerous issues when building your project.
I'm assuming that you have already downloaded and installed the necessary versions of Java and Gradle.
Windows
Open the Environment Variables window
1. Hit the Windows button or click on the Windows Search bar.

2. Search for: "environment variables" and open the "Edit the system environment variables" window.

3. Open the Environment Variables window from the System Properties window by clicking on the Environment Variables... button.

4. Add a JAVA_HOME variable that points to your Java folder.


5. Edit the Path in the System variables and add the folders for Java and for Gradle.
It is important to point to the bin folder for each of Java and Gradle.

6. After this, click on the OK buttons on each window to make sure you save the new configuration.
If you had a Command Prompt or an IDE (such as VS Code) open then proceed to close and reopen them to ensure that the new configurations are recognized by them.
And that is all. Now you should be able to run Java and Gradle commands from anywhere.
Comments