Install a compatible JDK, then install Apache Groovy. The groovy command runs scripts on the JVM. Follow the official installation guide, then verify the installation with groovy --version. The screenshots below illustrate an older Windows installation. Use the paths and versions for your machine.
A simple example
Run a first program
Start withA source file
Do thisRun the program
ResultReady
Print a single word to check that your tools can run a program.Lesson.groovy
println("Ready")
Output
Ready
Get a school laptop ready for class
A coding club shares its Windows laptops between classes. Open a fresh terminal and run groovy --version. A version line tells the next student that the shell can find the Groovy tool.
Java Development Kit (JDK) setup on Windows
Open a new terminal and run javac -version. If the command is unavailable, install the tool or check your PATH.
Install the JDK in the following default directory C:\Program Files\Java\jdk1.8.0_221 and you can move the JDK software to another location as per your wish.
Check the JDK is updated the Environment Variable or not, by opening the command prompt and execute the command java -version. It will show the installed JDK's version otherwise follow the below steps to setup the environment variable path.
Set Path of JDK in Windows system environment variables
1. Locate the directory containing javac.exe. Copy its path.
2. Press Windows + R and enter rundll32.exe sysdm.cpl,EditEnvironmentVariables to open Environment Variables.
Alternatively, search Windows for “environment variables”.
3. Under User variables, select Path and choose Edit.
4. Select New, paste the directory you copied, and confirm with OK.
5. Open a new terminal and run javac -version to verify that Windows can find the tool.
6. With the JDK available, configure the language tools next.
Advertisements
Groovy Standalone Command Line Compiler setup on Windows
Open a new terminal and run groovy --version. If the command is unavailable, install the tool or check your PATH.
Unzip the downloaded version of Groovy Compiler package in the following directory default directory C:\groovy-2.5.8 and you can move the Groovy Compiler to another location as per your wish.
Check the JDK is updated the Environment Variable or not, by opening the command prompt and execute the command groovy --version. It will show the installed Groovy's version.
Set Path of Groovy Compiler in Windows
1. Locate the directory containing groovy.bat. Copy its path.
2. Open the Windows Environment Variables dialog.
3. Select New, paste the directory you copied, and confirm with OK.
4. Open a new terminal and run groovy --version to verify that Windows can find the tool.