Search code examples
javagradlejavafxwindows-screensaverjavafx-gradle-plugin

Java screensaver loading the wrong main class, any ideas?


I'm building a Windows screensaver using Java, JavaFX, the JavaFX Packager, the Gradle JavaFX Packager plugin, etc. I generate various executable files with this configuration:

jfx {
    mainClass = "tech.project.project.ConfiguratorApp"
    vendor = "Project"
    appName = "Project"
    nativeReleaseVersion = version
    secondaryLaunchers = [
            [
                    appName  : "Project Renderer",
                    mainClass: "tech.project.project.RendererApp",
                    needMenu : true
            ],
            [
                    appName  : "Project Displayer",
                    mainClass: "tech.project.project.DisplayerApp",
                    needMenu : true
            ],
            [
                    appName  : "Project Screensaver",
                    mainClass: "tech.project.project.WinScreensaverApp",
                    needMenu : false
            ]
    ]
}

When configuring, previewing and testing the screensaver, everything works well, but when the screensaver actually runs, the main class seems to be DisplayerApp instead of WinScreensaverApp.

Any ideas why or how to gather more information about what's going on?

I managed to find the Windows command line:

C:\PROGRA~1\Project\PROJEC~1.SCR /s

Blast from the past! But I run that command manually in the console, I get the appropriate launcher called.


Solution

  • I sort of found a solution. I had various executables:

    • C:\Program Files\Project\Project A.exe
    • C:\Program Files\Project\Project B.exe
    • C:\Program Files\Project\Project C.exe
    • C:\Program Files\Project\Project D.scr

    and it looked like C:\Program Files\Project\Project A.exe was being run instead of C:\Program Files\Project\Project D.scr when C:\PROGRA~1\Project\PROJEC~1.SCR /s was executed.

    I changed the name of the screensaver to:

    • C:\Program Files\Project\ProD.scr

    and it started working correctly. I'm not exactly sure why, but since I won't investigate any further right now I wanted to post the solution in case someone else runs into a similar problem and this might shed some light on the issue.