0

I am trying to convert my javaFX program into native image, under windows, using the GluonFX plugin and Maven.

Since I use javafx WebView, the exe file generated, at the time of its execution, tells me the error:

java.lang.ClassNotFoundException: javafx.scene.web.WebView   

Mine is a simple program that uses WebView and WebEngine, fully functional under JVM, in NetBeans.

Is there an example of a program that uses WebView and is transformed into a native image with GluonFX?

The problem seems insurmountable for me and I ask for help. The following is the error message:

[lun nov 15 18:41:08 CET 2021][INFO] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @3722c145' 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB] Exception in Application start method 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB] Exception in thread "main" java.lang.RuntimeException: Exception in Application start method 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB]    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901) 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB]    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196) 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB]    at java.lang.Thread.run(Thread.java:829) 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB]    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:552) 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB]    at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138) 
[lun nov 15 18:41:09 CET 2021][INFO] [SUB] Caused by: java.lang.AssertionError: java.lang.ClassNotFoundException: javafx.scene.web.WebView

The pom file was generated by NetBeans, while the compilation was done via the terminal:

  • x64 Native Tools Prompt for VS 2019

My java program:

package com.gluonapplication;

import com.gluonhq.charm.glisten.application.MobileApplication;
import com.gluonhq.charm.glisten.visual.Swatch;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import java.io.IOException;
import javafx.scene.web.WebHistory;
import javafx.scene.web.WebHistory.Entry;

import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;

public class GluonApplication extends Application {// MobileApplication
    @Override
    public void start(Stage stage) throws Exception {
        StackPane root = new StackPane();        
        WebView view = new WebView();
        WebEngine engine = view.getEngine();
        engine.load("https://stackoverflow.com");
        root.getChildren().add(view);

        Scene scene = new Scene(root, 800, 600);
        stage.setScene(scene);
        stage.show();
    }
    public static void main(String args[]) {
        launch(args);
    }
}

The pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.gluonapplication</groupId>
    <artifactId>gluonapplication</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>GluonApplication</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>11</maven.compiler.release>
        <javafx.version>16</javafx.version>
        <attach.version>4.0.11</attach.version>
        <gluonfx.plugin.version>1.0.3</gluonfx.plugin.version>
        <javafx.plugin.version>0.0.6</javafx.plugin.version>
        <mainClassName>com.gluonapplication.GluonApplication</mainClassName>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>${javafx.version}</version>
        </dependency>
    
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-web</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gluonhq</groupId>
            <artifactId>charm-glisten</artifactId>
            <version>6.0.6</version>
        </dependency>
        <dependency>
            <groupId>com.gluonhq.attach</groupId>
            <artifactId>display</artifactId>
            <version>${attach.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gluonhq.attach</groupId>
            <artifactId>lifecycle</artifactId>
            <version>${attach.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gluonhq.attach</groupId>
            <artifactId>statusbar</artifactId>
            <version>${attach.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gluonhq.attach</groupId>
            <artifactId>storage</artifactId>
            <version>${attach.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gluonhq.attach</groupId>
            <artifactId>util</artifactId>
            <version>${attach.version}</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>Gluon</id>
            <url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>

            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>${javafx.plugin.version}</version>
                <configuration>
                    <mainClass>${mainClassName}</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <!-- Default configuration for running -->
                        <!-- Usage: mvn clean javafx:run -->
                        <id>default-cli</id>
                    </execution>
                    <execution>
                        <!-- Configuration for manual attach debugging -->
                        <!-- Usage: mvn clean javafx:run@debug -->
                        <id>debug</id>
                        <configuration>
                            <options>
                                <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000
</option>
                            </options>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Configuration for automatic IDE debugging -->
                        <id>ide-debug</id>
                        <configuration>
                            <options>
                                <option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
                            </options>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Configuration for automatic IDE profiling -->
                        <id>ide-profile</id>
                        <configuration>
                            <options>
                                <option>${profiler.jvmargs.arg1}</option>
                                <option>${profiler.jvmargs.arg2}</option>
                                <option>${profiler.jvmargs.arg3}</option>
                                <option>${profiler.jvmargs.arg4}</option>
                                <option>${profiler.jvmargs.arg5}</option>
                            </options>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>gluonfx-maven-plugin</artifactId>
                <version>${gluonfx.plugin.version}</version>
                <configuration>
                    <target>${gluonfx.target}</target>
                    <attachList>
                        <list>display</list>
                        <list>lifecycle</list>
                        <list>statusbar</list>
                        <list>storage</list>
                    </attachList>
                    <mainClass>${mainClassName}</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>ios</id>
            <properties>
                <gluonfx.target>ios</gluonfx.target>
            </properties>
        </profile>
        <profile>
            <id>android</id>
            <properties>
                <gluonfx.target>android</gluonfx.target>
            </properties>
        </profile>
    </profiles>
</project>
jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • See matrix of supported features with native image (table 3) at https://docs.gluonhq.com/#_platforms – José Pereda Nov 16 '21 at 18:18
  • I guess Jose's comment means that your desired configuration "native image, under windows" is not supported for the javafx-web module as the gluon's feature matrix for native images only supports Mac, Linux, Android and iOS versions. Therefore you will be unable to accomplish your goal using your current approach. – jewelsea Nov 17 '21 at 00:25

0 Answers0