MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

Revision 14 as of 2025-05-10 11:48:30
  • Groovy

Groovy

  • https://groovy-lang.org/

  • http://groovy-lang.org/groovy-dev-kit.html

  • http://groovy-lang.org/objectorientation.html

Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax

Install

   1 cd  ~/
   2 wget https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips/apache-groovy-binary-4.0.26.zip 
   3 unzip apache-groovy-binary-4.0.26.zip 
   4 
   5 nano ~/.bashrc
   6 # export GROOVY_HOME=$HOME/groovy-4.0.26
   7 # export PATH=$PATH:$GROOVY_HOME/bin
   8 . ~/.bashrc 
   9 groovysh
  10 # a = 1
  11 # print("aaa $a")
  12 # :q
  13 groovyConsole # opens window that allows to run groovy code
  14 

groovyc - compiler

  • nano MyClass.groovy

   1 class X{
   2   int amount
   3 }
   4 
   5 def x = new X()
   6 x.amount = 1
   7 println("${x.amount}")

   1 groovyc MyClass.groovy
   2 java -cp . -jar $GROOVY_HOME/lib/groovy-3.0.3.jar   MyClass
   3 java -jar $GROOVY_HOME/lib/groovy-3.0.3.jar   MyClass

swing - groovy

   1 import groovy.swing.SwingBuilder
   2 import java.awt.BorderLayout as BL
   3 
   4 count = 0
   5 
   6 def actionPerformedFn(){
   7   count++; 
   8   textlabel.text = "Clicked ${count} time(s)."
   9   println "clicked"
  10 }
  11 
  12 def quitFn(){
  13   System.exit(0) 
  14 }
  15 
  16 new SwingBuilder().edt {
  17   frame(title: 'Frame', size: [300, 300], show: true) {
  18     borderLayout()
  19     textlabel = label(text: 'Click the button!', constraints: BL.NORTH)
  20     button(text:'Click Me', actionPerformed: {actionPerformedFn()}, constraints:BL.WEST)
  21     button(text:'Quit', actionPerformed: {quitFn()}, constraints:BL.EAST)
  22   }
  23 }

   1 groovyc swing.groovy 
   2 java -cp .:$GROOVY_HOME/lib/groovy-3.0.3.jar:$GROOVY_HOME/lib/groovy-swing-3.0.3.jar swing

Map example

   1 def map=[:]
   2 map.x = 1
   3 map["y"] = "ab"
   4 print("Serialized map $map \n")
   5 
   6 print("Keys size: ${map.keySet().size()} \n")
   7 for(key in map.keySet()){
   8   print "$key: ${map["$key"]}\n"
   9 }
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01