Version of WebKit in JavaFX 8 WebView

后端 未结 1 1328
既然无缘
既然无缘 2020-12-09 09:49

What is the version of WebKit in JavaFX 8?

相关标签:
1条回答
  • 2020-12-09 10:39

    You can determine the base version of WebKit being used in WebView by querying the user agent string of the WebView's engine.

    web.getEngine().getUserAgent()
    

    This shows a WebKit version of 537.44 for Java 8u5.

    This is the upstream version of WebKit used in the JavaFX implementation before any downstream modifications were made to it to allow it to work with JavaFX.

    As new versions of Java 8 are released, the version of WebKit used in each version will change, but you should always be able to determine what is used by querying the User Agent String.

    Sample Code Output (on my machine)

    Java Version:   1.8.0_05-b13
    JavaFX Version: 8.0.5-b13
    OS:             Windows 7, amd64
    User Agent:     Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.44 (KHTML, like Gecko) JavaFX/8.0 Safari/537.44
    

    Sample Code

    import javafx.application.Application;
    import javafx.application.Platform;
    import javafx.scene.web.WebView;
    import javafx.stage.Stage;
    
    public class WebViewVersion extends Application {
        @Override public void start(Stage stage) {
            WebView web = new WebView();
            System.out.println(
                    "Java Version:   " + System.getProperty("java.runtime.version")
            );
            System.out.println(
                    "JavaFX Version: " + System.getProperty("javafx.runtime.version")
            );
            System.out.println(
                    "OS:             " + System.getProperty("os.name") + ", " 
                                       + System.getProperty("os.arch")
            );
            System.out.println(
                    "User Agent:     " + web.getEngine().getUserAgent()
            );
            Platform.exit();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }
    
    0 讨论(0)
提交回复
热议问题