Questions tagged [groovy-console]

The Groovy Console is a Java Swing based graphical user interface that is packaged with the Groovy distribution. It provides a simple but elegant way of executing interactive groovy scripts, with Groovy script entered in the top window, and the output of the script appearing in the lower window.

The Groovy Console is a Java Swing based graphical user interface that is packaged with the Groovy distribution. It provides a simple but elegant way of executing interactive groovy scripts, with Groovy script entered in the top window, and the output of the script appearing in the lower window.

The console is launched with one of a few variations of a command line call to groovyConsole. The variations comprise platform differences and executables that are compiled for some operating systems. It's location is:

<Groovy Home>\bin\groovyConsole[.*]

Variations include:

  • groovyConsole.bat (Windows)
  • groovyConsole.exe (Windows)
  • groovyConsole (Unix/Linux)

Groovy Console Snapshot

enter image description here

GroovyConsole Functions

Some of the useful functions provided in the UI are:

  • File Open / File Save / File New
  • New Window (multiple open windows supported)
  • Standard Edit Menu Functions (Copy/Paste/Undo/Redo/Search/Replace)
  • Various UI Property Toggles and Controls
  • Groovy AST Viewer
  • Groovy Variables Viewer
  • Compile Scripts
  • Run Scripts
  • Interrupt Running Script
  • Add JAR to Classpath
  • Add Directory to Classpath
162 questions
24
votes
5 answers

Groovy Console read input

I'm just starting to learn Groovy and I am experimenting in GroovyConsole. Is there a way I can read user input? I have tried the code below but I get an error. BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) print…
James
  • 307
  • 1
  • 3
  • 12
9
votes
4 answers

Error while executing groovy script

Code is a follows: class Book { private String title Book (String theTitle) { title=theTitle } String getTitle() { return title } } Book gina=new Book('Groovy in Action') assert…
learner
  • 2,480
  • 10
  • 50
  • 94
8
votes
5 answers

How do you configure GroovyConsole so I don't have to import libraries at startup?

I have a groovy script that uses a third party library. Each time I open the application and attempt to run my script I have to import the proper library. I would like to be able to open GroovyConsole and run my application without having to…
fooMonster
  • 987
  • 2
  • 9
  • 23
8
votes
1 answer

Is there a Groovy equivilent to Python Docstrings?

In Python, when commenting a function, you can do it in a way that makes it easier for documentation to be automatically generated. They refer to it as a docstring. Now that I've made an abstract class in Groovy that I'd like to pass around, is…
techHenson
  • 93
  • 1
  • 5
7
votes
1 answer

How to add multiple jars to the classpath of groovyConole/groovysh?

This feels ridiculous that I have to ask this, but I can't seem to add multiple jar files to the classpath for groovyConsole and groovysh. How do I add multiple jar files to the classpath? Here is what I've tried: groovyConsole -cp…
chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
5
votes
1 answer

Why groovyConsole supports `def name = "Neo"` while groovysh does not

Following is 2 lines of code: def name = "Neo" println name If I execute it in groovysh, I will get Unknown property: name error. If I execute it in groovyConsole, everything goes on well.
Neo
  • 2,196
  • 5
  • 32
  • 58
5
votes
4 answers

How to check whether the input is a number or string by using isNan() in groovy

Hello i am a beginner to groovy i am cofused how to check whether the given input is a number or not i tried the following def a= ' 12.571245ERROR' if(a.isNan()==0) { println("not a number") } else { println("number") } Kindly help me how to use…
shashank
  • 379
  • 5
  • 6
  • 15
5
votes
1 answer

Unix FIND command in Groovy

I am working on converting a KornShell (ksh) script to Groovy. I have the following Find command - what would be a Groovy way to do something similar, without relying on Unix commands (I need this to work cross-platform, so I can not do a "blah…
Steve
  • 4,457
  • 12
  • 48
  • 89
5
votes
1 answer

get path to groovy source file at runtime

Given the following directory structure: /home/some/random/foler/myScript.grooy ... how can I programmatically obtain the path to myScript.grooy parent directory right in the script itself? Ultimately I'm trying to read in several files from the…
vector
  • 7,334
  • 8
  • 52
  • 80
4
votes
1 answer

Find/Filter the lists with a specific key-value pair from a JSON ARRAY (list of maps)

I have a JSON array (list of maps) similar to: def listOfMap = [[TESTCASE:1, METHOD:'CLICK', RESULT:'PASS'], [TESTCASE:2, METHOD:'CLICK', RESULT:'FAIL'], [TESTCASE:3, METHOD:'CLICK', RESULT:'FAIL'], [TESTCASE:4,…
user1523153
  • 139
  • 3
  • 10
4
votes
2 answers

Why do I get a MissingPropertyException in the GroovyConsole?

When I execute the following script in the GroovyConsole it gives me a MissingPropertyException but I do not understand why: def a = 'A' def b() { println a } b() The following exception is thrown: groovy.lang.MissingPropertyException: No such…
Michael
  • 4,722
  • 6
  • 37
  • 58
3
votes
1 answer

Can't load oracle.jdbc.driver.OracleDriver in groovysh?

I am trying to go through a tutorial on GroovySQL. The database I need to connect to is an Oracle database. So I downloaded ojdbc6.jar and put it in ~/.groovy/lib/. If I put the following script in a .groovy file, I can do groovy testScript.groovy…
James Sumners
  • 14,485
  • 10
  • 59
  • 77
3
votes
1 answer

`groovyConsole` can not start on Ubuntu 18.04 with java 8, how to fix?

when I run groovyConsole from terminal, it give up with an exception: $ groovyConsole java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at…
Yu Jiaao
  • 4,444
  • 5
  • 44
  • 57
3
votes
1 answer

How to parse xml using groovy

I'm new to groovy xml parsing. I'm trying to parse the below xml file Team,

Please find below the test summary details for the 'Test' execution.

Transaction Summary Table:

syndy1989
  • 403
  • 10
  • 25
3
votes
2 answers

java javap and groovy bytecode comparison

Here is the code generated showed by javap when I asked him to display my compiled class (I selected method) int multiply(int, int); flags: Code: stack=2, locals=3, args_size=3 0: iload_1 1: iload_2 2: imul 3:…
lapots
  • 12,553
  • 32
  • 121
  • 242
1
2 3
10 11