Sunday 13 January 2019

Groovy: Generate .class file from groovy code


Groovy provides a compiler 'groovyc' to compile the groovy code.

How to generate class from groovy?
Use below command to generate .class file.
groovyc –d classes {GROOVY_FILE_NAME}

HelloWorld.groovy
int a = 10
int b = 20

print "Sum of 10 and 20 is ${a + b}"


Execute the statement 'groovyc -d classes HelloWorld.groovy', it creates a 'classes' folder and copy all the generated classes in it.


Previous                                                 Next                                                 Home

No comments:

Post a Comment