在JVM上设置默认参数

时间:2018-07-02 09:32:58

标签: java javafx jvm javafx-8 virtual-keyboard

我正在为组装系统开发javafx应用程序。 (WIN 7 EMB,JAVA 8)

此系统为触摸式(无键盘),但JVM默认未设置虚拟键盘

如何在JVM上一次确定地设置此参数?

-Dcom.sun.javafx.isEmbedded=true
-Dcom.sun.javafx.touch=true
-Dcom.sun.javafx.virtualKeyboard=javafx

感谢帮助!

2 个答案:

答案 0 :(得分:3)

在调用Application.launch(...)之前,JavaFX不会初始化。 例如,您应该尝试在main(String[] args)方法中设置系统属性:

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", "true");
    launch(args); // launch JavaFX
}

答案 1 :(得分:0)

最后,我找到了一个类似的解决方案,将我的主程序包装在另一个设置了jvm prop的程序中,然后再启动原始主程序。

 package launcher;

import application.Main;

public class myLauncher {

    public static void main(String[] args) {


        Main.main(null);

    }

}

这是主要的

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);
            }

(必须在罐子导出时标记->“在生成的罐子中提取所需的库”!)

很抱歉,但是我对此解决方案没有明确的解释!