I have an Swing application and I want to integrate JavaFx to it. The application runs well when starting from Eclipse.
package org.openjfx.hellofx;
import java.awt.BorderLayout;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javax.swing.JFrame;
public class AppRun {
public static void main(String[] args) {
JFrame f = new JFrame("TEST");
f.setSize(400, 400);;
f.getContentPane().setLayout(new BorderLayout());
JFXPanel panel = new JFXPanel();
Scene s = new Scene(new javafx.scene.control.Label("JavaFx"));
panel.setScene(s);
f.getContentPane().add(panel);
f.setVisible(true);
}
}
I don't know if you are creating a modular application, but I think you should consider using javafx-maven-plugin
instead of maven-shade-plugin
to generate a custom native image of your application. You already included the plugin, just run mvn clean javafx:jlink
. Check the plugin's GitHub README for configuration details: https://github.com/openjfx/javafx-maven-plugin
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.