javafx-maven-plugin icon indicating copy to clipboard operation
javafx-maven-plugin copied to clipboard

System.getProperty(“awt.toolkit”) is null when using javafx:run

Open GG-A opened this issue 5 years ago • 2 comments

here is code:

public class Test extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        System.out.println("AWT_TOOLKIT class name:" + System.getProperty("awt.toolkit"));
        System.out.println("user.timezone:" + System.getProperty("user.timezone"));

        primaryStage.show();
    }
}

when I run application in intellj idea directly, it will work well, print:

AWT_TOOLKIT class name:sun.awt.windows.WToolkit
user.timezone:Asia/Shanghai

but when I use javafx:run, it will print:

AWT_TOOLKIT class name:null
user.timezone:null

and I create runtime-image use jlink, and run launcher.bat, it will print:

AWT_TOOLKIT class name:null
user.timezone:null

how to do?

GG-A avatar Apr 22 '20 12:04 GG-A

Can you confirm if the project in both IntelliJ IDEA and Maven are running on the same JDK?

An easy way to do this would be to add:

System.out.println(System.getProperty("java.version"));

abhinayagarwal avatar Jun 08 '20 11:06 abhinayagarwal

@abhinayagarwal Yes. they both use jdk 14.

GG-A avatar Jun 09 '20 23:06 GG-A