A proposed solution (GitHub project) working on JDK 11 and later with corresponding version 11 of the openjfx
libraries.
The gist is that you get a hold of the reference by creating and initializing the gui app yourself, not let Application.launch
create the instance:
class Main {
void work() {
// Reference
Gui gui = new Gui(this/*for callbacks*/, "data", 'U', "initialize", 17, "with");
// Start
Platform.startup(() -> gui.start(new Stage()));
}
// Allow the Gui-app to return results by means of callback
void reportResult(double d, String desc) {
}
}
class Gui extends javafx.application.Application {
//...
// has a button that calls `Main.reportResult()` when pressed virtually returning values as any function call.
}
The project covers the use case of repeatedly/sequentially calling the gui utility application from within the main workflow app.