XCODX |

Groovy Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Groovy

If you've written a Gradle build script or a Jenkins pipeline, you've already written Apache Groovy — it's the scripting backbone of the JVM build ecosystem. Groovy layers optional typing, closures, and rich collection methods on top of Java, and any Java class works unchanged, which makes it ideal for gluing JVM code together fast. Recent Groovy releases added switch expressions, records, and sealed types to keep pace with modern Java. Test Groovy snippets here in a sandbox with a real terminal: output streams as it's produced, and reading from System.in waits for actual keystrokes, so trying a pipeline idea or a DSL trick takes seconds instead of a build cycle.

Hello World in Groovy

def reader = System.in.newReader()

print "Enter your name: "
def name = reader.readLine()

print "Enter three scores separated by spaces: "
def scores = reader.readLine().split(/\s+/).collect { it.toInteger() }

println "Thanks, ${name}!"
println "Average: ${scores.sum() / scores.size()}"
println "Sorted: ${scores.sort()}"

When to use Groovy

Debug the Groovy fragment inside a Jenkinsfile before committing it and waiting on a CI run, experiment with the collection methods (collect, findAll, inject, groupBy) that make Gradle scripts so terse, or use Groovy as a low-friction JVM scratchpad — no class declaration, no main method, just statements that run top to bottom. DevOps engineers maintaining pipeline libraries and Java developers curious about dynamic typing on the JVM both get answers here in one click.

Common questions

Can a Groovy script read from System.in on this page?

Yes — the script is attached to an interactive terminal, so System.in.newReader().readLine() (or a Scanner) pauses and waits for your typed line before continuing. That lets you rehearse scripts that expect runtime input, something Jenkins snippet testers and most online runners can't do.

Will my Jenkins pipeline steps like sh() and stage() work here?

Pipeline steps are provided by Jenkins plugins, not the Groovy language, so they won't resolve in a plain Groovy runtime. What you can verify here is everything else in a Jenkinsfile: closures, string manipulation, list and map wrangling, regex matching, and control flow — usually where the actual bugs live.

Does @Grab work to pull in dependencies?

No — @Grab needs network access to download artifacts, which the sandbox doesn't allow. You get the Groovy GDK plus the complete Java standard library, which covers file parsing, JSON-ish string handling, dates, regex, and collections without any external jars.

How Groovy runs on XCODX

Sandbox filename
Main.groovy
Entry point
single main source file
Editor grammar
groovy
Reading stdin
System.in
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

println "Hello from Groovy!"
println "Welcome to XCODX Online Compiler!"
def message = "Groovy is dynamic!"
println message