1

I'm building my first app in Java FX. (java.runtime.version=1.8.0_71-b15) Coding in Eclipse Java EE IDE for Web Developers. Version: Mars.2 Release (4.5.2) Build id: 20160218-0600

When I tied in my CSS file, my console started flooding with error messages like these:

Feb 14, 2018 4:13:25 PM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-text-base-color' while resolving lookups for '-fx-text-fill' from rule '*.button' in stylesheet jar:file:/Z:/Java/jdk1.8.0_71/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Feb 14, 2018 4:13:25 PM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-shadow-highlight-color' while resolving lookups for '-fx-background-color' from rule '*.button' in stylesheet jar:file:/Z:/Java/jdk1.8.0_71/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss

This is known bug, which apparently can't be fixed in Java 8 and hopefully will be fixed in Java 9. In the meantime, the best advice that people online seem to offer is to turn off the CSS logging. Here's that very advice from this site (https://bitbucket.org/controlsfx/controlsfx/issues/373/css-warnings-using-propertysheet-control):

I don't know that there is much that can be done - it looks like more of a general purpose JavaFX issue than something ControlsFX related. The visuals do not seem to be impacted, so one option is to simply turn off CSS logging, as such:

com.sun.javafx.Logging.getCSSLogger().setLevel(Level.OFF);

(The issue was also discussed on SO here: Java error on CSS, and elsewhere here: https://community.oracle.com/thread/2496427?tstart=0 but I'm not having any success zeroing in on an actual solution. The only practical advice I can find is from that first post, essentially saying, "Turn off CSS Logging with this command":

com.sun.javafx.Logging.getCSSLogger().setLevel(Level.OFF);

I'm fine with turning off the logging, my question is... how do I use this command? The poster who put up this advice just left the command, didn't say where to put it or anything. He (or she) is speaking in a shorthand I am not following.

Does anyone know where to apply this command? In the CSS file? Or in the actual Java code itself? If so, would "com.sun.javafx.Logging" be... the project path? Or is this a setting in Eclipse?

Many thanks, -RAO

Pete
  • 1,511
  • 2
  • 26
  • 49
  • It's just a method call... presumably the idea is you just call this in the `start()` method. Note, though, this won't work in Java 9, as the `com.sun` package will not be accessible. – James_D Feb 14 '18 at 21:34

1 Answers1

4

In Java 8u144, the package for the internal JavaFX logging utility is com.sun.javafx.util, not com.sun.javafx, so you would need to call:

com.sun.javafx.util.Logging.getCSSLogger()
    .setLevel(sun.util.logging.PlatformLogger.Level.OFF); 

at least for that version.

In that sample call, I fully qualified the Level class because, otherwise, it could be ambiguous as it differs from the standard java.util.logging.Level.

For Java 9 this isn't going to work, and you would receive the compiler error:

Error:(20, 23) java: package com.sun.javafx.util is not visible (package com.sun.javafx.util is declared in module javafx.graphics, which does not export it to the unnamed module).

With Java 9, maybe you could define your own LogFinder that handles the platform logging for the "javafx.css" logger (which is the text string of the logger name which you find when you look into the JavaFX source code), by ignoring messages sent to it.

There might be some easier way to do it using a logging.properties file that will work across most Java versions, but I'm not familiar enough with the platform logging system to know if that would work.

Yeah, it's all weirdly complicated . . .

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • wow, that works PERFECTLY! I'm so happy, I can't tell you. This is an area of Java & Eclipse I know nothing about. I need to read up on it some day... Thanks, I owe you one. :) – Pete Feb 15 '18 at 02:17
  • 1
    I didn't know much about it either. The public API for platform logging like the `LogFinder` is new for Java 9. – jewelsea Feb 15 '18 at 10:39
  • 3
    I believe this is multi-version compliant and does the trick: `ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class).setLoggerLevel("javafx.css", "OFF");` – Col-E Oct 16 '19 at 11:06