Over a million developers have joined DZone.

How to Debug a Groovy Script From Shell

Groovy is a dynamic language with powerful capabilities for typing and compilation on the Java platform; use this snippet to debug it without compiling.

· Java Zone

Navigate the Maze of the End-User Experience and pick up this APM Essential guide, brought to you in partnership with CA Technologies

Groovy is a scripting language, so it is possible to run Groovy code without compiling to Java byte code. The necessary condition is that Groovy is installed on your machine. Then, running a Groovy script in a shell looks like the following line:

~>groovy TestScript.groovy

Now, something is wrong with the script on a special environment. You want to debug your Groovy script from the shell.

Fortunately, it works for Groovy just like for Java. You only have to export the Java options for debugging:

~>export JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=y"

Now, we can debug our script running from the shell with our favorite IDE.

~>groovy TestScript.groovy
Listening for transport dt_socket at address: 4000

Thrive in the application economy with an APM model that is strategic. Be E.P.I.C. with CA APM.  Brought to you in partnership with CA Technologies.

Topics:
groovy ,debugging ,cli

Published at DZone with permission of Sandra Parsick, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}