JAVAFX 11不支持ECMAScript6和CSS3 [英] JAVAFX 11 not supporting ECMAScript6 and css3
问题描述
我正在使用JAVA FX 11的某些绘图工具创建一个Web浏览exp,但是在尝试加载使用let
和const
的javascript代码时,这些变量只会被忽略并引发异常.我正在使用maven 3.8.0,Java 1.8和JavaFX 11.
I am creating a web browsing exp with some drawing tool with JAVA FX 11 but while trying to load the javascript code which has let
and const
used these variables are simply getting ignored and throwing the exceptions. I am using maven 3.8.0, Java 1.8 and JavaFX 11.
代码如下:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12-ea+9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>12-ea+9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>12-ea+9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12-ea+9</version>
</dependency>
和Java代码
public static void main(String[] urls) {
String javaVersion = System.getProperty("java.version");
String javafxVersion = System.getProperty("javafx.version");
System.out.println(javaVersion + " java....... fx........ " + javafxVersion);
Application.launch(urls);
}
@Override
public void start(Stage stage) throws Exception {
Parameters parameters = getParameters();
List<String> raw = parameters.getRaw();
String url = "http://example.com/";
if (raw.size() != 0) {
url = raw.get(0);
}
/*
* WebConsoleListener.setDefaultListener((webView, message, lineNumber,
* sourceId) -> { System.out.println(message + "[at " + lineNumber + "] [in " +
* sourceId + "]"); });
*/
Pane root = new Pane();
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
// Load the Google web page
webEngine.load(url);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("IWB");
stage.show();
// mainStage = stage;
root.getChildren().add(webView);
webView.setMinSize((screenSize.getWidth() - 120), (screenSize.getHeight() - 60));
btns.setMinHeight(screenSize.getHeight() - 60);
stage.setOnCloseRequest(e -> {
// Platform.exit();
// System.exit(0);
});
// Platform.setImplicitExit(false);
}
推荐答案
我正在使用maven 3.8.0,Java 1.8和JavaFX 11.
I am using maven 3.8.0, Java 1.8 and JavaFX 11.
简而言之,请使用最新的Java8.Java似乎正在该版本上更新WebKit,因此较新的版本将产生较新的功能.阅读下面的详细信息,特别是8u5
和8u251
之间的区别.
In short, use the latest Java 8. Java seems to be updating WebKit on that version, so newer versions will yield newer features. Read the below for the breakdown, specifically the differences between 8u5
and 8u251
.
- JavaFX 11.0.2:WebKit版本
606.1
(Safari 12.x ) - JavaFX 15-ea + 3:WebKit版本
609.1
(Safari 13.x 一个>)- 注意:尽管名字,JavaFX 15与JDK11兼容
- JavaFX 11.0.2: WebKit Version
606.1
(Safari 12.x) - JavaFX 15-ea+3: WebKit Version
609.1
(Safari 13.x)- Note: Despite the name, JavaFX 15 is JDK11 compatible
- Java 8u5: WebKit Version
537.44
(Safari 7.x) - Java 8u251: WebKit Version
609.1
(Safari 13.x)
一些有用的信息:
- Oracle Java 1.8附带了自己的捆绑Java FX版本,通常不能覆盖该版本.要使用Java FX11,您将需要使用Java 11运行该项目并将System属性
java.library.path
设置为FX框架的位置. - 根据 https://stackoverflow.com/a/23228558/3196753 使用
web.getEngine().getUserAgent()
技术获得的版本
- 假设WebKit〜= Safari. Safari自Safari 10起具有 ECMAScript 6支持.
- 警告::使用Oracle Java会对商业许可产生严重影响.有关更多信息,请参见: Java仍免费2.0. 3 .如果此许可证导致您的应用出现问题,建议使用OpenJDK 11.本文提供了一些不受这些商业许可限制的提供商.
- Oracle Java 1.8 comes with its own bundled Java FX version, which generally can't be overridden. To use Java FX11, you will need to run the project with Java 11 and set the System property
java.library.path
to the location of the FX framework. - Version obtained using
web.getEngine().getUserAgent()
technique per https://stackoverflow.com/a/23228558/3196753 - Assumes WebKit ~= Safari. Safari's has ECMAScript 6 support since Safari 10.
- Warning: There are serious commercial licensing implications to using Oracle's Java. More about that here: Java Is Still Free 2.0.3. It's recommended to use OpenJDK 11 if this license causes issues with your app. The article has several providers that are available without these commercial licensing restrictions.
这篇关于JAVAFX 11不支持ECMAScript6和CSS3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!