Javafx stage.setFullScreen throw exception after gluon:build and .exe run but not after javafx:run

69 views Asked by At

I'm trying to create my first .exe from a javafx application. I'm using maven and gluon to achieve my goal. When I launch my app with mvn javafx:run everything run fine. So I try to package my app in a .exe using gluonfx:build and I get a .exe, everything seems okay, I have no error in maven build or link log. Unfortunately when I try to run the .exe nothing happened, I have this log using gluonfx:nativerun :

[jeu. nov. 17 21:01:45 CET 2022][INFO] ==================== RUN TASK ====================
[jeu. nov. 17 21:01:45 CET 2022][INFO] [SUB] nov. 17, 2022 9:01:45 PM com.sun.javafx.application.PlatformImpl startup
[jeu. nov. 17 21:01:45 CET 2022][INFO] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @6b71769e'
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB] Exception in Application start method
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB] Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at java.lang.Thread.run(Thread.java:833)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:143)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB] Caused by: java.lang.AssertionError: java.lang.ClassNotFoundException: com.sun.javafx.tk.quantum.OverlayWarning
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.util.Utils.forceInit(Utils.java:869)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.tk.quantum.OverlayWarningHelper.<clinit>(OverlayWarningHelper.java:44)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.tk.quantum.OverlayWarning.<clinit>(OverlayWarning.java:50)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.tk.quantum.WindowStage.applyFullScreen(WindowStage.java:685)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.tk.quantum.WindowStage.setFullScreen(WindowStage.java:734)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.stage.Stage.doVisibleChanged(Stage.java:1184)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.stage.Stage$1.doVisibleChanged(Stage.java:190)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.stage.StageHelper.visibleChangedImpl(StageHelper.java:63)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.stage.WindowHelper.visibleChanged(WindowHelper.java:77)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.stage.Window$12.invalidated(Window.java:1212)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.stage.Window.setShowing(Window.java:1239)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.stage.Window.show(Window.java:1254)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at javafx.stage.Stage.show(Stage.java:277)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at fr.icom.info.m1.balleauprisonnier_fx.App.start(App.java:115)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at java.security.AccessController.executePrivileged(AccessController.java:169)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at java.security.AccessController.doPrivileged(AccessController.java:399)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST_Runnable_run_16403f8d32adb631126daa893e5e80085c5d6325(JNIJavaCallWrappers.java:0)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    ... 3 more
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB] Caused by: java.lang.ClassNotFoundException: com.sun.javafx.tk.quantum.OverlayWarning
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at java.lang.Class.forName(DynamicHub.java:1121)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    at com.sun.javafx.util.Utils.forceInit(Utils.java:866)
[jeu. nov. 17 21:01:46 CET 2022][INFO] [SUB]    ... 28 more

It appears to be the line stage.setFullScreen(true); in my App.java file that makes my .exe not running because when I replace it with stage.setMaximized(true); my .exe is launching correctly.

As the gluon documentation says (https://docs.gluonhq.com/#platforms_windows) I have installed graalvm-svm-java17-windows-gluon-22.1.0.1-Final, and the required visual studio things, like windows sdk, latest msvc version ... My java and javafx version are 17.0.1

I first thought about a javafx version problem so I change it to 11 but the same problem happens, as the problem doesn't show using javafx:run I really don't know where the problem may come from ...

Here is my pom.xml file, maybe it will helps.

<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>fr.icom.info.m1.</groupId>
  <artifactId>balleauprisonnier_fx</artifactId>
  <version>0.0.1</version>
  <packaging>jar</packaging>

  <name>balleauprisonnier_fx</name>
  <url>http://maven.apache.org</url>

  <properties>
    <maven.compiler.target>9</maven.compiler.target>
    <maven.compiler.source>9</maven.compiler.source>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <javafx.version>17.0.1</javafx.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <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>org.openjfx</groupId>
      <artifactId>javafx-fxml</artifactId>
      <version>${javafx.version}</version>
    </dependency>
  </dependencies>
  <build>
      <sourceDirectory>src</sourceDirectory>
      <testSourceDirectory>test</testSourceDirectory>
      <resources>
        <resource>
            <directory>ressources</directory>
        </resource>
     </resources>
      <plugins>
        <plugin>
          <groupId>org.openjfx</groupId>
          <artifactId>javafx-maven-plugin</artifactId>
          <version>0.0.8</version>
          <configuration>
            <mainClass>fr.icom.info.m1.balleauprisonnier_fx.App</mainClass>
          </configuration>
        </plugin>
      

    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.1</version>

                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
            <manifest>
                <mainClass>fr.icom.info.m1.balleauprisonnier_fx.App</mainClass>
            </manifest>
        </archive>
                </configuration>

                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
            

<plugin>
    <groupId>com.gluonhq</groupId>
    <artifactId>gluonfx-maven-plugin</artifactId>
    <version>1.0.16</version>
    <configuration>
        <mainClass>fr.icom.info.m1.balleauprisonnier_fx.App</mainClass>
    </configuration>
</plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/gluonfx/x86_64-windows</outputDirectory>
              <resources>          
                <resource>
                  <directory>ressources</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
      </plugin>

            <!-- 
            <plugin>
                <groupId>com.coderplus.maven.plugins</groupId>
                <artifactId>copy-rename-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <id>copy-file</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <sourceFile>ressources/launcher_windows.bat</sourceFile>
                             <destinationFile>target/launcher_windows.bat</destinationFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->
            
      </plugins>
    </build>
</project>

Thank you in advance

1

There are 1 answers

1
Baptiste Cld On

Thanks to what @Slaw says I tried this code and it works:

stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
stage.setFullScreen(true);

Based on it's answer, I suppose that this code blocked the overlay warning and therefore no exception is thrown. Not sure of this one but my .exe works now, thank you !

Edit : Based on what @José Pereda says I added <reflectionList>com.sun.javafx.tk.quantum.OverlayWarning</reflectionList> to my pom.xml and it works fine, as it keeps the default behavior this answer seems to be a better one