Reputation: 445
I would like to know if it is possible to call java methods in groovy language. Everybody seems to ask how to call groovy from java code. But I would like to know how it is the other way around. Thanks
Upvotes: 1
Views: 4487
Reputation: 96385
Groovy uses the JVM and uses java classes normally. If you look in the $GROOVY_HOME/lib directory you’ll see there are jar files there, many of which were built from java code.
Add a jar to the classpath and groovy can see its classes (use import to specify what classes you want, exactly like with java). You can also drop jars into $GROOVY_HOME/lib if you want to make them available to groovyconsole or groovysh.
Upvotes: 1