Matt Chad Matt Chad - 1 year ago 216
Java Question

Java WebView generate an exception on Windows XP

This is my first question here, so I hope to be clear.
I am developing a simple JavaFX Application, the only thing it has to do is showing a web user interface.
Everything seems to be ok, I exported the Runnable JAR File from Eclipse and I tested it on Window 10 and 7, but when I put the jar on Window XP OS, I have the following:

Exception in Application start method
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(
at Source)
Caused by: java.lang.UnsatisfiedLinkError: Invalid URL for class: rsrc:com/sun/g
at com.sun.webkit.WebPage.lambda$static$39(
at Method)
at com.sun.webkit.WebPage.<clinit>(
at javafx.scene.web.WebEngine.<init>(
at javafx.scene.web.WebEngine.<init>(
at javafx.scene.web.WebView.<init>(
at application.Main.start(
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(Platfor
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.
at Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformI
at Method)
... 1 more

Here is my code:

package application;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.stage.Stage;
import javafx.util.Callback;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;

public class Main extends Application {
public void start(Stage stage)
stage.setMinWidth( 800 );
stage.setMinHeight( 600 );
stage.setMaximized( true );
Scene scene = new Scene(new Group());

WebView browser = new WebView();
WebEngine we = browser.getEngine();

//setting personalized context menu
browser.setContextMenuEnabled( false );
//createContextMenu( browser );

//preventing bug when maximmizing
stage.maximizedProperty().addListener(new ChangeListener<Boolean>()
public void changed( ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1 )
System.out.println("maximized:" + t1.booleanValue());

//intercepting javascript alert
browser.getEngine().setOnAlert( new EventHandler<WebEvent<String>>()

public void handle(WebEvent<String> e)
Alert alert = new Alert( AlertType.WARNING );
alert.setTitle( "MyApp" );
alert.setHeaderText( null );
alert.setContentText( e.getData() );
System.out.println("JS alert() message: " + e.getData() );


//intercepting javascript confirm
browser.getEngine().setConfirmHandler( new Callback<String, Boolean>()
public Boolean call( String s )
Boolean ret;
ButtonType ok, cancel;

ok = new ButtonType( "Ok" );
cancel = new ButtonType( "Abort" );

Alert alert = new Alert( AlertType.CONFIRMATION );
alert.setTitle( "SameLAB" );
alert.setHeaderText( s );
alert.setContentText( null );
alert.getButtonTypes().setAll( ok, cancel );

if( alert.getResult() == ok )
ret = true;
ret = false;

return ret;

ScrollPane sp = new ScrollPane();
sp.setFitToWidth( true );
sp.setFitToHeight( true );

//loading and showing content
scene.setRoot( sp );
stage.setScene( scene );;

public static void main(String[] args)

Hope that someone cal help me, thank you!

Answer Source

I encountered this issue today after upgrading to the last JDK 121. The same problem is with early release JDK 122.

As for now WebView and HTMLEditor works fine when using JDK 77 (probably some later versions too (as stated in the link below - 102), but i didn't check out for it). Problem is with loading library NativeLibLoader.loadLibrary("jfxwebkit"); There were some vague suggestions that some new Microsoft Visual C++ Redistributables may help.

Edited. It's already in bugreport: and, alas, closed with the Resolution: "Won't Fix".

So, one option is left - provide bundled JRE version 1.8.0_102 or less for Windows XP. Another temporary dirty option: bundle your application with jfxwebkit.dll from 1.8.0_102 and add somewhere in your code before WebView instance created (for example, in start(Stage primaryStage) method)

if ("Windows XP".equals(System.getProperty(""))){ 
System.load(ABS_PATH_TO_JFXWEBKIT_DLL + "\\jfxwebkit.dll");}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download