Online Groovy Compiler
Run Groovy scripts online with Groovy 6.0 on Java 17. Write statements at the top level or define classes, press Run, and see what the script prints beside your code, with errors shown by line. Scripts can read input from System.in as they run, and the Groovy and Java libraries are ready to use.
How to run Groovy code online
- This page opens with Groovy selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
Groovy 6.0 on Online IDE
- Your script runs with Groovy 6.0 on Java 17, so statements can sit at the top level without a class.
- System.in.newReader().readLine() reads a line of input, and a prompt from print shows before it waits.
- String methods such as isInteger() and toInteger() check and convert what was typed.
- The Groovy and Java standard libraries are available, but @Grab cannot download dependencies.
Example: a Groovy program that reads input
print 'Enter a whole number: '
def line = System.in.newReader().readLine()?.trim()
if (line?.isInteger() && line.toInteger() > 0) {
def n = line.toInteger()
println "Divisors of $n: ${(1..n).findAll { n % it == 0 }.join(', ')}"
} else {
println 'Please enter a whole number above zero.'
}
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Groovy version does Online IDE use?
Groovy 6.0 on Java 17, running your file as a script.
Can a Groovy script read input?
Yes. Make one reader with def reader = System.in.newReader() and call reader.readLine() for each line, or use a java.util.Scanner. Type into the output panel while the script waits and press Enter.
Can I write classes?
Yes. Define classes in the script and use them from its top-level statements, or write a class with a static main method.
Does @Grab work?
No. Scripts cannot download libraries. The Groovy and Java standard libraries are available.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.