Idea + Maven deploy packaged JavaFX project encountered pit

Idea written with a JavaFX project, create artifacts, always encounter an error class not found when the build artifacts, run the build out of exe executable file, as shown below

 

Follow the prompts to start a class path that is not set up, but how to change all the same mistakes, the Internet also can not search people experiencing the same problem with me.

 

Later built a JavaFX project without Maven, can be found in the normal deployment, you can find the Main class.

Modified a little between the last two items, a little bit comparison and found the problem and the definition of static property initialization code such as the following four static properties and are initialized when the class loader

French test found that the control variable, simply define a static property, then there is no problem can be found in the Main class, but if the initialization assignment behind the definition statement, it will lead to error above the figure of the class not found

public class Main extends Application {
    private Logger logger = LoggerFactory.getLogger(Main.class);

    private Stage primaryStage;
    private BorderPane rootLayout;

    private SoundService soundService = new SoundService();

    private static Image fileIcon = new Image(Main.class.getResource("/images/iconfinder_icon-55-document-text_315178.png").toString(), 16, 16, true, true);
    private static Image folderIcon = new Image(Main.class.getResource("/images/iconfinder_icon-94-folder_314778.png").toString(), 16, 16, true, true);
    private static Image musicIcon = new Image(Main.class.getResource("/images/iconfinder_icon-63-document-music_315187.png").toString(), 16, 16, true, true);
    private static Image audioMediaIcon = new Image(Main.class.getResource("/images/iconfinder_multimedia-44_2849792.png").toString(), 16, 16, true, true);

/*
其余无关代码
*/ }


If a member property is defined as the following logger and the initialization assignment behind the definition statement, the following figure error occurs when you run the exe file: Error invoking method.

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/rudyabel/p/11844643.html
Recommended