1
votes

I am trying to open a webpage in javafx webview . Its throwing a fatal error exception

Error is this-

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6e98299b, pid=4116, tid=4224

JRE version: 7.0_10-b18 Java VM: Java HotSpot(TM) Client VM (23.6-b04 mixed mode, sharing windows-x86 ) Problematic frame: V [jvm.dll+0xb299b]

Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

An error report file with more information is saved as: C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\NetCheck\hs_err_pid4116.log

If you would like to submit a bug report, please visit: http://bugreport.sun.com/bugreport/crash.jsp

What is the reason for the above error , I am using the following code.

 import javax.swing.*;
 import java.awt.*;
 import javafx.application.Platform;
 import javafx.embed.swing.JFXPanel;
 import javafx.scene.Group;
 import javafx.scene.Scene;
 import javafx.scene.web.WebEngine;
 import javafx.scene.web.WebView;



public class Browser extends javax.swing.JFrame 
{

  JFXPanel fxpanel;
  WebEngine eng;
  public Browser() {
  initComponents();
  setLayout(null);
  fxpanel=new JFXPanel();
  add(fxpanel);
  fxpanel.setBounds(50,50,700,500);
  setBounds(0,0,1024,768);

 }


 private  void initFx(final JFXPanel fxpanel)

 {
  try
   {
    Group group= new Group();
    Scene scene= new Scene(group);
    fxpanel.setScene(scene);    
    WebView webview = new WebView ();
    group.getChildren().add(webview);
    webview.setMinSize(700,500);
    webview.setMaxSize(700,500); 
    webview.setVisible(true);
    eng= webview.getEngine();
    eng.setJavaScriptEnabled(true);
    eng.load("http://www.google.com");
   }
   catch(Exception ex)
   {
     ex.printStackTrace();
   }
  }

  public static void main(String args[])
  {
  Browser b1= new Browser();
  b1.show();

  }

   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)


   {
     Platform.runLater(new Runnable() {
      public void run()
      {
        initFx(fxpanel);
     }}
       );

  }
1
post this bug on oracle you may get the solutionadesh singh

1 Answers

0
votes

You need to update your JDK, you have a very old 1.7.0u10 version (December 2012) and the latest JDK 7 version is 1.7.0u45.

Be aware, that WebView in JDK 7 contains some minor bugs which are fixed in JDK 8 and are unlikely to be fixed in JDK 7. Some of the bugs I noticed are with font rendering, i.e. Font Awesome and Ace Editor didn't work for me well in JDK 7.

UPDATE

You demo is working on JDK 1.7.0u40. You need to call initFx in the fx app thread:

  Platform.runLater(new Runnable() {
        @Override
        public void run() {
            initFx(fxpanel);
        }
  });