The Personal Blog of Todd Sharp

Grails on Raspberry Pi Part 3 - Installing Groovy And Grails

Posted By: Todd Sharp on 3/16/2017 8:27 GMT
Tagged: Grails, Groovy, Groovy On Raspberry Pi, Java, Raspberry Pi

The first step in getting working with Grails on the Raspberry Pi is, of course, installing Grails.  I've been somewhat dreading this post because it's pretty hard to make installing software interesting, but it's necessary so we'll trudge through it and try to have a good time with it.  If you've never worked with Groovy or Grails before, that's quite alright.  I'll do my best to make sure that I keep things basic, but at the same time you might want to run through some Groovy or Grails tutorials (there are plenty out there).  Also, feel free to ask questions.  My goal is to help you get a web site up and running on the Raspberry Pi.

There are two ways to install Grails.  One way is to download it yourself, and the right way is to install SDKMAN and use it to install Grails for you.  Follow the instructions on the Grails download page to install SDKMAN, but before you do make sure that you have "zip" installed first via:

sudo apt-get install zip

Note:  SDKMAN will prompt you to run the following command after it installs:

Please open a new terminal, or run the following in the existing one:
source "/home/pi/.sdkman/bin/"

Don't skip this step, else you'll get errors complaining that "sdk: command not found".  Once SDKMAN is installed, install Grails via:

sdk install grails

Seriously, that's all it takes. Since you didn't pass a specific version to SDKMAN it'll grab the latest version and install it (which is 3.2.7 as of the time this post was published).  

Well, I kinda lied - if you actually want to run Grails, you'll have to set the JAVA_HOME environment variable so that Grails knows where Java is.  After you set JAVA_HOME, run:

grails -version

Since Grails uses the Groovy language, it'll also install the required Groovy version, but I typically like to also install a standalone version of Groovy for one off scripts and testing purposes.  To install Groovy, just do:

sdk install groovy

I typically also create a folder called "Projects" in my home directory so feel free to do something similar at this point.  If you want to create a simple test Groovy script, create a file called test.groovy and enter the following using nano (or vi if you're crazy):

println new Date().format('MM-dd-yyyy')

Run it from the command line with:

groovy test.groovy

And it'll output the current date.  

And that's all it takes to get Groovy and Grails installed on the Raspberry Pi.  In the next post we'll look at creating a slightly more complex Groovy script to illustrate how easy it is to use for simple scripting and even more complex tasks.

Image by Comfreak from Pixabay

Related Posts

Enterprise Messaging via Oracle Advanced Queuing with Autonomous DB & Micronaut

Enterprise Messaging via Oracle Advanced Queuing with Autonomous DB & Micronaut

I’ve written about messaging many, many times on this blog. And for good reason, too. It’s a popular subject that developers can’t seem to get enough of...

Authenticating Users with Oracle IDCS via OpenId Connect and Micronaut

Authenticating Users with Oracle IDCS via OpenId Connect and Micronaut

Security is the most important aspect of your web application. Fortunately, there are tools available to help make life much easier when dealing with things...

Adding Tracing to Your Distributed Cloud Native Microservices

Adding Tracing to Your Distributed Cloud Native Microservices

When adopting cloud-native technologies and certain architectures such as the microservice pattern, observability and monitoring become a huge need and...

Note: Comments are currently closed on this blog. Disqus is simply too bloated to justify its use with the low volume of comments on this blog. Please visit my contact page if you have something to say!