I tested your problem both with groovyConsole (from groovy-sdk-2.1.0) and with IntelliJ IDEA 12.0.3. The only exception I got was:
Caught: java.lang.NoClassDefFoundError: javafx/application/Application
java.lang.NoClassDefFoundError: javafx/application/Application
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
... 1 more
This was because the JavaFX runtime (jfxrt.jar) was not in the classpath. This can be fixed with
mvn com.zenjava:javafx-maven-plugin:1.3:fix-classpath
The command above is taken from the JavaFX Maven Plugin Wiki. You have to execute it only once. After that change both groovyConsole and IntelliJ are working. I had to restart the groovyConsole, this was not necessary for IntelliJ.
What is interesting is that I don't see the GroovyFx-jar under "External Libraries". I am using plain IDEA community edition without any plugins.
The Hello World from the GroovyFX homepage works out of the box in IDEA but not in the groovyConsole - I also get the "java.lang.ClassNotFoundException: groovyx.javafx.GroovyFX". I managed to let it run with the following code, but it is not a good solution, since it works only on the first run, then you have to restart the groovyConsole:
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)
@Grab(group='org.codehaus.groovyfx', module='groovyfx', version='0.3.1')
import static groovyx.javafx.GroovyFX.start
start {
stage(title: 'GroovyFX Hello World', visible: true) {
scene(fill: BLACK, width: 500, height: 250) {
hbox(padding: 60) {
text(text: 'Groovy', font: '80pt sanserif') {
fill linearGradient(endX: 0, stops: [PALEGREEN, SEAGREEN])
}
text(text: 'FX', font: '80pt sanserif') {
fill linearGradient(endX: 0, stops: [CYAN, DODGERBLUE])
effect dropShadow(color: DODGERBLUE, radius: 25, spread: 0.25)
}
}
}
}
}
I am not sure but I think the reason is this bug here. Should be fixed in Groovy 2.2, we will see.