How to run Groovy 3.0.0 with JDK 10 on Windows 7+?
Since the advent of the Java Module System, and the removal of the classes under the javax.xml.bind package from the JDK, running Groovy became problematic under Java versions 9+. Groovy 3.0.0-alpha-3 installed on Windows 7 and using JDK 10.0.2 cannot run out of the box, instead we get this error message, running hello.groovy (containing only the print "Hello World" line)
Running a groovy script results in error. |
Also groovy console can't run scripts:
Groovy Console can't run scripts |
The solution is easy, setting the JAVA_TOOL_OPTIONS environment variable to
--add-modules=java.xml.bind will solve the problem. (System Properties dialog/ Advanced tab / Environment Variables button / Environment variables dialog / System variables list / New ... )
Setting the system property JAVA_TOOL_OPTIONS to --add-modules=javax.xml.bind |
Starting a console after this setting and running groovy scripts still gives a lot of warnings, but the scripts are run (note the "Hello World" at the bottom):
The output of running the hello.groovy script after setting the JAVA_TOOL_OPTIONS environment variable |
The Groovy Console is also working properly:
Output of the Groovy Console after setting the JAVA_TOOL_OPTIONS environment variable |