Groovy
lastmod 2024-11-05created 2014-08-069 edits
Groovy is a dynamic object-oriented programming language that adds features of Python, Ruby, Smalltalk, and others to Java.
A representative project is the build automation system gradle.
Features
- A dynamically typed programming language that runs on the Java virtual machine.
- Builds on Java's strengths and adds features influenced by programming languages such as Python, Ruby, and Smalltalk.
- Java programmers can use modern programming techniques without much learning.
- Supports domain-specific languages and simplified syntax, making code easier to read and maintain.
Java Binding Embedding Groovy
JavaEmbedGroovy.java file:
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
public class JavaEmbedGroovy {
public static void main(String[] args) {
Binding binding = new Binding();
binding.setVariable("evento", "FTD");
binding.setVariable("linguagem", "Groovy");
GroovyShell shell = new GroovyShell(binding);
System.out.println("-- Inicio Groovy script --");
Object result = shell.evaluate("println \"$evento $linguagem\"; return 'Haaaaa'");
System.out.println("Resultado: " + result);
System.out.println("-- Fim Groovy script --");
}
}
See also
Favorite site
- Groovy web site
- Wikipedia (en) Groovy
- Stackoverflow: Bind a java class as a closure into a groovy-script
- Stackoverflow: How to create a Java String from the contents of a file?
-
Embedding Groovy -
Korean Embedding Groovy
Turotial
- Groovy basics
- Groovy integration
- Groovy Korean Beginners Tutorial
- Groovy - Syntax (focusing on differences from Java)
Pages that link here