2

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);
     }}
       );

  }
Sandeep Sehrawat
  • 576
  • 2
  • 7
  • 18

1 Answers1

0

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);
        }
  });
Andrey Chaschev
  • 16,160
  • 5
  • 51
  • 68
  • In JDK 8 jdbc:odbc support is not present, what is the alternate – Sandeep Sehrawat Nov 28 '13 at 11:57
  • You demo is working for me, I've updated the sample. I think it should also work at u45. – Andrey Chaschev Nov 28 '13 at 12:01
  • Ya its working on some systems this error is related to JVM as i know but i have no solution about it – Sandeep Sehrawat Nov 28 '13 at 12:04
  • Could you post an [SSCCE](http://sscce.org/) of the code which is not working for 1.7.0u45? If it really doesn't work, it might also be an issue of Swing+FX combination, you could try using JavaFX alone. Here is a browser demo: http://stackoverflow.com/a/20135387/1851024. – Andrey Chaschev Nov 28 '13 at 12:08