JavaFX - virtual keyboard does not appear when creating a Jar application

I created a JavaFX application in IntelliJ14.14 that will use the JavaFX virtual keyboard . I will add the following properties to the mainApp class controller:

public static void main(String[] args) {
    System.setProperty("com.sun.javafx.isEmbedded", "true");
    System.setProperty("com.sun.javafx.touch", "true");
    System.setProperty("com.sun.javafx.virtualKeyboard", "javafx");
    launch(args);
}

When I launch the application from IntelliJ, everything works fine. The virtual keyboard works fine.

But when I generate the application Jar file from Build -> Build Artifacts ... -> Build and Run, the keyboard is never displayed because the VM options are not set.

Something I'm missing ...?

Thanks in advance...

EDIT

I found a way to do this work by executing a file with cmd using this command:

java -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard="javafx" -Dcom.sun.javafx.touch=true -jar myApp.jar 

, Jar...

, ...

.bat :

start javaw -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard="javafx" -Dcom.sun.javafx.touch=true -jar myApp.jar 

, .bat jar, ...

+4
1
public class MyApp {  
    public static void main(String[] args) {  

        if (args.length == 0) {  
            try {  
                // re-launch the app itselft with VM option passed  
                Runtime.getRuntime().exec(new String[] {"java", "-Dcom.sun.javafx.isEmbedded=true", "-Dcom.sun.javafx.virtualKeyboard=\"javafx\"", "-Dcom.sun.javafx.touch=true", "-jar", "myApp.jar"});  
            } catch (IOException ioe) {  
                ioe.printStackTrace();  
            }  
            System.exit(0);  
        }  

        // Run the main program with the VM option set  
        //...  
        //...  
    }  
}  
+3

Source: https://habr.com/ru/post/1614175/


All Articles