I'm a software developer with a great interest in data analysis and statistics.
We can use the Groovy programming language for scripting our software builds and automate some otherwise cumbersome tasks. Groovy is a JVM language and is similar to Java, but less verbose so excellent for doing scripting. We use it with the Gradle build management system or for example for setting up some easy Spring projects in Groovy with Spring Boot.
Make Sure You Have Java JDK Installed
You’ll need to make sure you have a working Java environment setup. You need to check if you have the JDK installed. Open a command prompt and type java -version. If it shows the current version of the JDK you are set for installing Groovy. Just to make sure, it is best you have a recent version 1.7 or upwards. If you don't have the JDK or are running an older version you'll have to install it. More on installing the JDK here.
Do You Already Have Groovy?
Next we’ll check if you have Groovy already installed. If you have it installed you’ll also be able to see the version and if necessary download a more recent version. Let’s open a command prompt. I use (shortcut: windows key + R) to open the run box where I type cmd and press ok.
Next you can enter the following in the command prompt groovy -v. Which, if you haven’t installed it, results in:
‘groovy’ is not recognized as an internal or external command,
operable program or batch file.
Downloading The Groovy Language
So you don’t have grooy installed. We’ll download groovy at http://www.groovy-lang.org/, on the groovy website you do to the download section which you can find in the top menu. When you are in the download section. You can download the binary of the most recent distribution.
When the download is finished you can extract the zip to a location where you want groovy installed. I have a section on my harddrive for development related tools and packages. I create a folder there named groovy and extra this distribution to that folder.
Adding Groovy To Environment Variables
You can find your environment variables section when you open the “control panel” -> “system” -> “advanced system settings”.
When you open environment variables you can choose to add a new variable. For variable name we enter GROOVY_HOME. Next we enter the variable value. This is the location of your groovy installation. In my case that is C:\Development\groovy\groovy-2.4.8. Then we just press ok and should see the newly added variable.
When we’ve added the variable we should edit the “path” variable. We need to add our groovy variable to the path and the \bin to it. %GROOVY_HOME%\bin and save the path.
When all of the above is entered succesfully when can try our groovy -v command again in the prompt and shoud see our groovy version and JVM installation we have.
Groovy For Java Developers
© 2017 Sam Shepards