Hello World from Groovy
Once we have successfully installed Groovy we can start executing scripts both in the command prompt (Groovy Shell) and in the Groovy Console.
I have worked on a tool to execute scripts, you can test the Online Groovy Console here.
Executing a “Hello World Groovy!”
We open the Windows console or the shell of your choice in your OS (The following examples are given with Windows)
Command: groovy
A series of options are listed that can be combined with the groovy
command, if for example we
want to write a “Hello Groovy World!” in console just write the following
groovy -e "println "Hello Groovy World!"
Command: groovysh (groovy shell)
The command groovysh activates the groovy shell in the Windows console, giving us the possibility
to execute more complex scripts from it, whenever we execute a method in Groovy, it returns the last
value we tried and denotes it with 3 signs =
and a greater than >
, as you can see in this example
the return value of the println
method is null
Command: groovyConsole
The groovyConsole command opens an instance of the console that Groovy installations by default for script execution.
Doubts, comments or contributions are welcome, have a great weekend and see you next time.