10.7 Using Java Classes from Groovy
Using Java classes from Groovy is simple and direct. If the Java classes we want to use
are part of the JDK, we import the classes or their packages in Groovy just
like in Java. By default Groovy imports a number of packages and classes
(see Section 2.1, From Java to Groovy),
so if the class we want to use is imported already (such as java.util.Date),
then we just use it—no import is needed.
If we want to use one of our own Java classes, or classes that are not part of the standard JDK,
we can import them in Groovy just like we would in Java. Make sure to import the necessary packages or classes, or
refer to the classes by their fully qualified names. When running groovy, specify the path to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access