Reputation: 59
I am currently struggling with installation/getting started with Groovy.
With a file called Hello.groovy
I have written:
println "Hello, Groovy!"
When I use groovyc Hello.groovy
to create the class file, the compilation works. However, when I try to run the class file using groovy Hello.class
I get the following error:
``
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/Users/lukemccartney/Desktop/apache-groovy-course/getting-started/groovyc/Hello.class: 1: Unexpected character: '�' @ line 1, column 1.
����@YHellogroovy/lang/Script
Hello.groovy$staticClassInfo*Lorg/codehaus/groovy/reflection/ClassInfo;__$stMCZ()V
^
1 error ``
I tried installing groovy via sudo apt-get install groovy
on my Ubuntu VM and I get the same problem when I run groovyc Hello.groovy
and groovy Hello.class
.
Upvotes: 0
Views: 331
Reputation: 59
dagget's response the answer above works flawlessly and is exactly what I was looking for. As far as I am aware, groovy
does not create jar files.
Upvotes: 0
Reputation: 171184
The groovy
cli app runs groovy scripts
The groovyc
cli app compiles groovy scripts to JVM bytecode
You can't run JVM bytecode directly with the groovy
cli app.
To run it, use the java
command:
java -cp ~/path/to/groovy/lib/groovy-4.0.11.jar:. Hello
Upvotes: 2