【发布时间】:2014-06-13 18:47:12
【问题描述】:
public class JavaApplication3 {
/**
* @param args the command line arguments
*/
public void initAndShowGUI() {
// This method is invoked on the EDT thread
JFrame frame = new JFrame("Swing and JavaFX");
final JFXPanel fxPanel = new JFXPanel();
frame.add(fxPanel);
frame.setSize(300, 200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Platform.runLater(new Runnable() {
@Override
public void run() {
initFX(fxPanel);
}
});
}
private void initFX(JFXPanel fxPanel) {
// This method is invoked on the JavaFX thread
Scene scene = createScene();
fxPanel.setScene(scene);
}
private Scene createScene() {
Group root = new Group();
Scene scene = new Scene(root, Color.ALICEBLUE);
WebView browser;
browser = new WebView();
//browser.setContextMenuEnabled(false);
browser.autosize();
WebEngine webEngine = browser.getEngine();
String Qlink = "https://www.google.ca";
webEngine.load(Qlink);
root.getChildren().add(browser);
return (scene);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
System.setProperty("http.proxyHost","10.10.6.61");
System.setProperty("http.proxyPort","6666");
System.setProperty("https.proxyHost","10.10.6.61");
System.setProperty("https.proxyPort","6666");
JavaApplication3 j = new JavaApplication3();
j.initAndShowGUI();
}
});
}
}
这是与oracle的示例代码90%相同的程序。 要么我刷新页面两次,要么再等一会儿,JVM 会自行崩溃。 我做错了什么以至于结果是这样的?请指出。 它很容易复制。我正在使用 java7u22,jfxrt 是包含的 jre 默认值。 非常感谢您的帮助!
编辑: 我将在 IDE 上发布很长的错误显示。如果您要求,我还将提供核心转储日志文件。很抱歉语法可能让你难以理解我。
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005c2728e3, pid=812, tid=5280
#
# JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [glass.dll+0x128e3]
#
# Core dump written. Default location: C:\Users\robin.ASIGRA\Documents\NetBeansProjects\JavaApplication3\hs_err_pid812.mdmp
#
# An error report file with more information is saved as:
# C:\Users\robin.ASIGRA\Documents\NetBeansProjects\JavaApplication3\hs_err_pid812.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
06/13-14 更新
我的操作系统是window server R2 2008,java版本是7 我确实尝试将 java 版本更新到 8,但问题仍然存在。 此应用程序必须在 java7 环境中构建。 我发现它是 windows server R2 2008 上 java7 的 bug,并且有一个解决方案。
此问题发生在 Windows Server 2008 R2 SP1 和 Java 7u45 (JavaFX 2.2.45) 上。我已经解决了它启用桌面体验功能(在远程服务器上,转到管理工具-> 服务器管理器)。请注意,此功能还启用了 Windows Defender 服务,并且 Microsoft doc 没有报告它。
我做完之后,问题就解决了。
【问题讨论】:
-
首先,不是Java,是你。其次,请发布堆栈跟踪、MCVE 和具体错误。最后,修正你的语法和格式。
-
@AnubianNoob 先生,我已经完成了您要求的事情。请随时提出问题,我可以通过电子邮件将核心转储日志发送给您。您可能想在您自己的环境中测试我的代码。如果一切正常,请告诉我。
-
如果您升级到更新的 JVM,它的行为方式是否相同?
-
@James_D 请查看我的更新。