OS: Linux Mint 18.3 The combo I want to run is: Groovy 3.0.+ (app and testing code) & Java 11+ & JavaFX 11+
Having had a little help (see comments here) I can now do this using a gradle.build file (including outputting an executable using the Gradle "installDist" task from the application
plugin).
I've also managed to do this from a non-Gradle Groovy-enabled project in IntelliJ, by configuring the classpath and module-path appropriately.
My file javaFXTest.groovy looks like this (NB this is the Groovy script which I get IntelliJ to run):
package core
import javafx.application.Application
import javafx.fxml.FXMLLoader
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.stage.Stage
Application.launch( GrApp, args)
class GrApp extends Application {
@Override
void start(Stage primaryStage) {
Parent root = FXMLLoader.load(getClass().getResource("/dialog1.fxml"))
primaryStage.title = "Hello World"
primaryStage.scene = new Scene(root, 1200, 800)
primaryStage.show()
}
}
I'm just wondering, for the sake of interest, how this is actually done in terms of a CLI groovy
command. I thought it might be something like this:
groovy -cp .:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/* --module-path /home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml core/javaFXTest.groovy
oops:
Caught: java.io.FileNotFoundException: /home/mike/IdeaProjects/JavaFXExp2/AppTest/src/main/groovy/--module-path (/home/mike/IdeaProjects/JavaFXExp2/AppTest/src/main/groovy/--module-path)
... it clearly doesn't recognise --module-path
as a configurable option, confirmed by going groovy --help
. I searched on this and found nothing. And yet IntelliJ manages to run this script: the --module-path
and --add-modules
options are added as VM options to the run configuration. Anyone know how this might be done as a CLI command?