Installing Grails on Windows, Mac, and Linux: A Step-by-Step Guide

Grails is a full-stack web application framework that provides a productive environment for building web applications. It is built on top of well-known frameworks such as Spring and Hibernate, which makes it a powerful and flexible option for web development.
In this tutorial, we will show you step-by-step guide on how to install Grails on Windows, Mac, and Linux operating systems.

Overview of Grails installation process

Before installing Grails, you should ensure that your system meets the following requirements:

  1. Java Development Kit (JDK) version 8 or later.
  2. At least 2GB of RAM.
  3. At least 1GB of free disk space.

Before you can start using Grails to develop web applications, you need to install it on your system. The installation process varies slightly depending on your operating system, but generally involves the following steps:

  1. Install Java: Grails requires Java to be installed on your system. You can download and install Java from the Oracle website or use a package manager like Homebrew on macOS or apt-get on Linux.
  2. Download Grails: You can download the latest version of Grails from the official website or using a package manager like SDKMAN.
  3. Install Grails: Once you have downloaded Grails, you can install it using the installation wizard or by extracting the files to a directory of your choice.
  4. Set up environment variables: To use Grails from the command line, you need to set up the GRAILS_HOME and PATH environment variables on your system.
  5. Verify the installation: You can verify that Grails is installed correctly by running the grails --version command in a terminal window.

    Please refer to the below screenshots if you are facing difficulty

If you’re new to Grails and want to know more about the framework, check out our tutorial on: Introduction to Grails Framework: Tutorial for Beginners

How to Install Grails on Windows

Follow these steps to install Grails on Windows:
Step 1: Download and Install Java (version 8 or later)
Before installing Grails, you need to install the Java Development Kit (JDK). You can download the latest version of the JDK from the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html).

Step 2: Download and Install Grails
Download the latest version of Grails from the official Grails website (https://grails.org/download.html). Once the download is complete, unzip the file to a location of your choice.

Step 3: Set up Environment Variables
To run Grails from the command line, you need to set up the GRAILS_HOME and PATH environment variables. To do this, follow these steps:

  1. Right-click on the My Computer icon and select Properties.
  2. Click on the Advanced System Settings link.
  3. Click on the Environment Variables button.
  4. Under System Variables, click New.
  5. Enter GRAILS_HOME as the variable name and the path to the directory where Grails is installed as the variable value (e.g., C:\grails-5.3.2).
  6. Edit the PATH variable and add %GRAILS_HOME%\bin to the end of the variable value (e.g., ;%GRAILS_HOME%\bin).
  7. Click OK to save the changes.

Step 4: Verify the Installation
To verify that Grails is installed correctly, open a new command prompt and type the following command:
grails --version
This should display the version of Grails that you have installed.

How to Install Grails on Mac

Follow these steps to install Grails on Mac:
Step 1: Download and Install Java (version 8 or later)
Before installing Grails, you need to install the Java Development Kit (JDK). You can download the latest version of the JDK from the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html).
Step 2: Download and Install Grails
Download the latest version of Grails from the official Grails website (https://grails.org/download.html). Once the download is complete, unzip the file to a location of your choice.
Step 3: Set up Environment Variables
To run Grails from the command line, you need to set up the GRAILS_HOME and PATH environment variables. To do this, follow these steps:

  1. Open the Terminal application.
  2. Enter the following command to open the .bash_profile file: nano ~/.bash_profile
    Add the following lines to the file:
    export GRAILS_HOME=/path/to/grails
    export PATH=$PATH:$GRAILS_HOME/bin

    Replace /path/to/grails with the path to the directory where Grails is installed.
  3. Press Ctrl+X to exit the editor and save the changes.

Step 4: Verify the Installation
To verify that Grails is installed correctly, open a new terminal window and type the following command:
grails --version
This should display the version of Grails that you have installed.

Please refer to the below screenshots if you are facing difficulty

How to Install Grails on Linux

Follow these steps to install Grails on Linux:
Step 1: Download and Install Java (version 8 or later)
Before installing Grails, you need to install the Java Development Kit (JDK). You can download the latest version of the JDK from the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html).
Step 2: Download and Install Grails
Download the latest version of Grails from the official Grails website (https://grails.org/download.html). Once the download is complete, unzip the file to a location of your choice.
Step 3: Set up Environment Variables
To run Grails from the command line, you need to set up the GRAILS_HOME and PATH environment variables. To do this, follow these steps:

  1. Enter the following command to open the .bashrc file: nano ~/.bashrc
  2. Open a terminal window.
  3. Add the following lines to the file:
    export GRAILS_HOME=/path/to/grails
    export PATH=$PATH:$GRAILS_HOME/bin
    Replace /path/to/grails with the path to the directory where Grails is installed.
  4. Press Ctrl+X to exit the editor and save the changes.

Step 4: Verify the Installation
To verify that Grails is installed correctly, open a new terminal window and type the following command:
grails --version
This should display the version of Grails that you have installed.

How to Install Grails with SDKMAN

SDKMAN is a tool that makes it easy to install and manage software development kits (SDKs) on your system. To install Grails with SDKMAN, follow these steps:
Step 1: Install SDKMAN
Visit the SDKMAN website (https://sdkman.io/install) and follow the instructions to install SDKMAN on your system. or Simple open new Terminal and run below command:
curl -s https://get.sdkman.io | bash
Step 2: Install Grails
Enter the following command to install the latest version of Grails:
sdk install grails
This will download and install the latest version of Grails.
Step 3: Verify the Installation
To verify that Grails is installed correctly, open a new terminal window and type the following command:
grails --version
This should display the version of Grails that you have installed.

Please refer to the below screenshots if you are facing difficulty

Install Grails with SDKMAN
Install Grails with SDKMAN

Grails without installation (Just set path in IDE)

If you don’t want to install Grails on your system, you can still use it by setting the path in your IDE. Here are the steps to set up Grails in your IDE without installation:

  1. Download the Grails binary zip file from the official website given earlier.
  2. Extract the zip file to a directory of your choice.
  3. Open your IDE and create a new Grails project.
  4. In the project settings or preferences, navigate to the Grails SDK section.
  5. Click “Add” and select the directory where you extracted the Grails binary zip file.
  6. Click “OK” to save the changes and close the settings/preferences window.
  7. You can now start using Grails in your project without having to install it on your system.

By setting up Grails in your IDE this way, you can use it for development without having to worry about installing it on your system. This is especially useful if you are working on a shared computer or do not have administrative privileges to install software. However, keep in mind that this approach may have some limitations, such as not being able to use specific features or plugins that require installation.

Troubleshooting Common Installation Issues

If you encounter any issues during the installation process, here are some common solutions:

  • Version Conflicts: Make sure that you have installed the correct version of Java and Grails that are compatible with each other. Check the Grails documentation for the recommended version of Java for the version of Grails you are installing.
  • Permissions Issues: Make sure that you have the necessary permissions to install Java and Grails on your system. On Windows, make sure that you are logged in as an administrator. On Mac and Linux, use the sudo command to run the installation commands as a superuser.
  • Java Installation Issues: If you encounter issues during the Java installation process, try downloading and installing the Java Development Kit (JDK) instead of the Java Runtime Environment (JRE). Also make sure that your PATH environment variable includes the correct Java installation directory.

How to Uninstall Grails from Your System

If you need to uninstall Grails from your system, follow these steps:

  1. Delete the directory where Grails is installed.
  2. Remove the GRAILS_HOME and PATH environment variables from your system.

On Windows, you can uninstall Grails by navigating to the Grails directory and deleting it. You should also remove the “GRAILS_HOME” and “Path” environment variables that were set up during installation.
On Mac and Linux, you can uninstall Grails by deleting the Grails directory and removing any environment variables from your shell configuration file. To do this, open your shell configuration file (e.g., ~/.bashrc or ~/.bash_profile) and remove the “GRAILS_HOME” and “Path” environment variables.
Once you have removed the Grails directory and environment variables, Grails will be completely uninstalled from your system.

Conclusion

In this article, we have provided a step-by-step guide on how to install Grails on Windows, Mac, and Linux operating systems. To install Grails on Windows, you need to download and install Java, download and extract the Grails binary distribution, set up environment variables, and verify the installation. On Mac and Linux, you can use SDKMAN to install Grails by running a few commands in your terminal. We have also covered how to troubleshoot common installation issues, how to uninstall Grails, and how to use Grails without installation. By following these steps, you can easily install Grails and start using it to develop web applications on your preferred operating system.

Don’t forget to subscribe to our blog for more web development tips, tutorials, and insights.

RahulAuthor posts

Avatar for Rahul

Rahul is a passionate IT professional who loves to sharing his knowledge with others and inspiring them to expand their technical knowledge. Rahul's current objective is to write informative and easy-to-understand articles to help people avoid day-to-day technical issues altogether. Follow Rahul's blog to stay informed on the latest trends in IT and gain insights into how to tackle complex technical issues. Whether you're a beginner or an expert in the field, Rahul's articles are sure to leave you feeling inspired and informed.

No comment

Leave a Reply

Your email address will not be published. Required fields are marked *