I have a modular JavaFX application with the following Java code:
package webbrowser;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebView;
import javafx.scene.web.WebEngine;
import javafx.stage.Stage;
public class WebBrowser extends Application {
@Override
public void start(Stage stage) {
WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
webEngine.load("http://www.oracle.com");
Scene scene = new Scene(browser, 500, 500);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Here is the module-info.java file:
module webBrowser {
requires javafx.controls;
requires javafx.web;
exports webbrowser;
}
I compile the modular JavaFX application with the following command:
javac -d out --module-source-path . --module-path $JAVAFX_SDK/libs:$JAVAFX_JMODS --module webBrowser
I package the modular JavaFX application with the following command:
jpackage --type dmg --module-path $JAVAFX_JMODS:$JAVAFX_SDK/lib:out --add-modules javafx.controls,javafx.web,javafx.graphics,javafx.media --module webBrowser/webbrowser.WebBrowser
Then I save the application in my /Applications folder (I'm on Mac OS) and open the application. The application opens a 500x500 window, but it doesn't render any graphics, and it doesn't open a web browser. The application just opens a white blank 500x500 window.
Why isn't the application running properly?
When I run the application with java (and forego jpackage) the application runs fine in the JVM, opens a web browser, and opens the oracle.com webpage.
java --module-path out:$JAVAFX_JMODS:$JAVAFX_SDK/lib --add-modules javafx.controls,javafx.web --module webBrowser/webbrowser.WebBrowser
Why doesn't the application work when I use jpackage, install the dmg and run the Mac OS app?