1

Greetings

I have deployed a simple JavaFX application using msi installer that was created by jpackage. When double-clicking on the application icon installed in Windows 10 "program files" directory, it displays an error "Failed to launch JVM". Prior to deployment, I tested the application jar file from the command prompt without any problem. When checking the application installation directory (under "C:\Program files") it has all the runtime dlls and so on, so I am not sure what causes this error? Here is the japckage command I used to build the runtime image:
jpackage  --type msi --name FileChooser -p "%JAVAFX_HOME%\lib;%M2_REPO%;org\openjfx\mavenfxfilechooser\mavenfxfilechooser.jar" --module "org.openjfx.mavenfxfilechooser/org.openjfx.mavenfxfilechooser.FileChooserApp"

Update

Following the recommendation given in the comment section, I installed the JMODS on my machine and issued a jpackage command line to point to the JMODS files instead of JAVAFX_HOME as follow:
jpackage --type msi --name FileChooser -p "%JMODS_HOME%;%M2_REPO%;C:\Users\hrh74\Downloads\Lib\file\org\openjfx\mavenfxfilechooser" --module "org.openjfx.mavenfxfilechooser/org.openjfx.mavenfxfilechooser.FileChooserApp"

I installed the application using the MSI runtime image and this certainly solved the" Failed to launch JVM" problem. The application started, however, I have a WebView component that should display content from https://us.yahoo.com when the user clicks on a "Yahoo" button and this doesn't seem to be working when the application run as a self-contained app but it works when I run the jar file from the command line. Do I need to add anything to the jpackage?
Please let me know if the source code and FXML file are needed.
Thanks

Anthony
  • 135
  • 1
  • 14
  • Am currently having the same issue, am unable to make request from deployed application . how did you resolve it ? – AngularNinjaAvenger Feb 03 '21 at 08:37
  • I was never able to get this working and because of this post, I got banned from using the stackoverflow, so I no longer can post. I cannot figure out how one person in the community can lock you out but apparently, in Stackoverflow one person can block someone at whim – Anthony Feb 04 '21 at 09:45
  • Thanks for responding Anthony, I guess I have to build another application ‍♂️ – AngularNinjaAvenger Feb 05 '21 at 10:13
  • @AngularNinjaAvenger Can you [try this solution](https://stackoverflow.com/a/66498233/6395627) and let me know if it works for you? – Slaw Mar 05 '21 at 19:06

2 Answers2

1

Your original problem has to do with missing native code. But you appear to have already solved that problem by using the JMOD files for JavaFX provided by Gluon. So I'll try to help solve your other issue regarding https://us.yahoo.com not loading in the WebView once you create a self-contained application.

When trying to load that website myself I was running into the same issue as you. Though sometimes I'd get a "we're working on the problem" page response, other times the entire application would become unresponsive, and yet other times nothing would happen (the load would just seem to fail "gracefully"). This happened with other websites as well, not just Yahoo. After some testing I was finally able to get the following error:

java.lang.Throwable: SSL handshake failed
        at javafx.web/javafx.scene.web.WebEngine$LoadWorker.describeError(Unknown Source)
        at javafx.web/javafx.scene.web.WebEngine$LoadWorker.dispatchLoadEvent(Unknown Source)
        at javafx.web/javafx.scene.web.WebEngine$PageLoadListener.dispatchLoadEvent(Unknown Source)
        at javafx.web/com.sun.webkit.WebPage.fireLoadEvent(Unknown Source)
        at javafx.web/com.sun.webkit.WebPage.fwkFireLoadEvent(Unknown Source)
        at javafx.web/com.sun.webkit.network.URLLoaderBase.twkDidFail(Native Method)
        at javafx.web/com.sun.webkit.network.HTTP2Loader.notifyDidFail(Unknown Source)
        at javafx.web/com.sun.webkit.network.HTTP2Loader.lambda$didFail$18(Unknown Source)
        at javafx.web/com.sun.webkit.network.HTTP2Loader.lambda$callBackIfNotCanceled$10(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

That indicated to me the application created by jpackage was missing some crypto libraries. From here I just guessed, but inclulding:

--add-modules jdk.crypto.cryptoki,jdk.crypto.ec

When running jpackage seemed to solve the problem. I don't know if both modules are needed, or if only one is needed (or if adding either one implicitly adds the other).


Side note: When scrolling through https://us.yahoo.com I would frequently get the following warnings:

Mar 05, 2021 12:10:40 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl onError
WARNING: onError, errCode=0, msg=Could not create player!

And:

Mar 05, 2021 12:10:41 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl$CreateThread run
WARNING: CreateThread ERROR: java.lang.UnsupportedOperationException: Unsupported protocol "data"

I would get that warning regardless of how the application was packaged. I don't know how to solve the problem, or if there even is a solution without modifying the JavaFX code itself.

Slaw
  • 37,820
  • 8
  • 53
  • 80
  • 2
    'unsupported protocol "data"' error is because the media source (website) is returning the media as a "data:" URI. This is part of the HTML5 standard so it should be supported (and is indeed supported by GStreamer the downstream audio library used by JavaFX WebKit). However the JavaFX implementation (com.sun.media.jfxmediaimpl.platform.gstreamer.GSTPlatform.java) of sending media to GStreamer restricts it to only "file", "http" and "https" protocols. See here: https://github.com/shitapatilptc/java/blob/master/src/javafx.media/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTPlatform.java – JoeDuncan Mar 25 '21 at 19:36
0

Have you seen running JavaFX application after jpackage? Try to download Gluon jmods and use it instead of %JAVAFX_HOME%

  • Please can you give more details in your answer and not only throw a link to improve the quality of your answer. – Teasel Sep 18 '20 at 07:28
  • @Domino walker: Thanks for the link. I took a cursory look and it seems like it will solve my problem. Once, I get a moment, I will try it and let you know. The contributor to that answer 'Slaw' seem very knowledgable and he has help me to overcome issues in the past. – Anthony Sep 18 '20 at 08:19
  • what exsactly you need to do is change %JAVA_HOME%\lib to path where you put JMODs for JavaFX which has been downloaded from Gluon site – domino walker Sep 18 '20 at 11:05
  • For me it works well for JDK 14, I think it's about version of JavaFX – domino walker Sep 18 '20 at 11:24
  • try to add path to your compiled classes and remove "org\openjfx\mavenfxfilechooser\mavenfxfilechooser.jar"? – domino walker Sep 18 '20 at 12:16
  • I removed the jar file from the module path and used --main-jar switch to point to the jar file that contains the compile classes (if I understood you correctly), however jpackage doesn't seem to like having --main-jar and --module simultaneously. What other option tells jpackage the location of compiled classes? Thanks – Anthony Sep 18 '20 at 12:36
  • Add to path parameter output directory that contains compiled .class files – domino walker Sep 18 '20 at 12:48
  • Ok, I added the full path to the directory that contains the compiled classes and the jar file. The Web View still doesn't show the content from us.yahoo.com. I have added an update section to my post to show more details – Anthony Sep 18 '20 at 13:47