I am just launching a javaFX application via Scala. Here is one Java example and here another here.
The first issue is that we cannot launch Scala JavaFX applications as per the examples in Java. So in Scala we do this. Why? javaFX applications need start the platform first. It can only be done once. In Java the launch methods first initialize the platform, then uses reflection to find the class and instantiates the class. After instantiation it calls the start method.
Usually the above works ok, but I wanted to implement something like this. In other words unlike the standard format I need to have static methods that access a JavaFX application from another thread. I am assuming that static methods are only possible via Scala singletons. So I coded everything as a Singleton. However as per the first message I got an error because no default constructor was found by Java.
What I did was create a HeadlessWebKit
class and effectively made the singleton a companion object. Now Java finds the default constructor and initializes the class. It also seems to access the companion object methods correctly.
I just want to make sure that this will not have Java compatibility issues down the line. I have tested with OpenJDK11, Scala 2.12.10 and OpenFX 11.0.2.