I have a project that is building a system in Scala. Its GUI is being defined using the ScalaFX system, which is a thin layer that delegates to the underlying JavaFX tools, components and features.
The application was running with a fine-looking GUI in early testing, but all the builds were being driven by the IDE. For various reasons, we wanted to migrate the build to the SBT system.
But upon launching with
$ sbt run
we would get entries like this in the console:
[info] Running StartHere
May 21, 2016 8:50:28 PM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "com/sun/javafx/scene/control/skin/modena/modena.css" not found.
The application would compile without issue and would run correctly, but looked terrible. For instance there would be no edges visible for buttons or for text box input fields.
Obviously, a dependency was missing from the build.sbt file. It was easy enough to add, with a line like the following:
unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/lib/ext/jfxrt.jar"))
With that in place, the code continued to compile without issues, and the run no longer contained the warning. And since the basic stylesheet was now being found at runtime, the GUI once again looked like it should.
Why did it behave this way? I have not researched it, for the moment it was enough to fix the GUI and continue development. My guess is that it is rooted in the location of the jfxrt.jar which we, in past Java versions and past JavaFX projects, needed to occasionally move manually into the /lib/ext folder for some clients. In my Java 8 installation, the jfxrt.jar is already in that folder, so perhaps something in the dependencies of this project is expecting it elsewhere.
But why just at runtime? The stylesheet resource is not loaded at compile time, the compiler trusts that the requested resource will be found at runtime. In this case it was not.
The application was running with a fine-looking GUI in early testing, but all the builds were being driven by the IDE. For various reasons, we wanted to migrate the build to the SBT system.
But upon launching with
$ sbt run
we would get entries like this in the console:
[info] Running StartHere
May 21, 2016 8:50:28 PM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "com/sun/javafx/scene/control/skin/modena/modena.css" not found.
The application would compile without issue and would run correctly, but looked terrible. For instance there would be no edges visible for buttons or for text box input fields.
Obviously, a dependency was missing from the build.sbt file. It was easy enough to add, with a line like the following:
unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/lib/ext/jfxrt.jar"))
With that in place, the code continued to compile without issues, and the run no longer contained the warning. And since the basic stylesheet was now being found at runtime, the GUI once again looked like it should.
Why did it behave this way? I have not researched it, for the moment it was enough to fix the GUI and continue development. My guess is that it is rooted in the location of the jfxrt.jar which we, in past Java versions and past JavaFX projects, needed to occasionally move manually into the /lib/ext folder for some clients. In my Java 8 installation, the jfxrt.jar is already in that folder, so perhaps something in the dependencies of this project is expecting it elsewhere.
But why just at runtime? The stylesheet resource is not loaded at compile time, the compiler trusts that the requested resource will be found at runtime. In this case it was not.