针对javafx应用程序的Gradle构建:虚拟键盘由于缺少System属性而无法使用 [英] Gradle build for javafx application: Virtual Keyboard is not working due to missing System property

查看:166
本文介绍了针对javafx应用程序的Gradle构建:虚拟键盘由于缺少System属性而无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是一个javafx应用程序,我们为这个应用程序开发了一个gradle构建系统。可以使用以下gradle任务创建jar文件:

 任务fatJar(类型:Jar){
manifest {
属性'Main-Class':'myProject'
}
baseName = project.name +'-all'
from {configurations.compile.collect {it.isDirectory() ?它:zipTree(it)}}
使用jar $ b排除'META-INF / * .RSA','META-INF / * .SF','META-INF / * .DSA'
$ b

}



问题是我们想要使用虚拟键盘(javafx),因此我们需要设置以下系统属性:

  systemProperty' com.sun.javafx.isEmbedded','true'
systemProperty'com.sun.javafx.touch','true'
systemProperty'com.sun.javafx.virtualKeyboard','javafx'

我可以在gradle build中设置这个属性,还是需要用

$启动应用程序b
$ b

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



祝好运

__________________________________-



解决方案弗雷德里克亨利:-))是写一个包装pper class like

  public class AppWrapper 
{
public static void main(String [] args)throws例外
{
Class<?> app = Class.forName(myProject);
方法main = app.getDeclaredMethod(main,String []。class);
System.setProperty(com.sun.javafx.isEmbedded,true);
System.setProperty(com.sun.javafx.touch,true);
System.setProperty(com.sun.javafx.virtualKeyboard,javafx);
Object [] arguments = new Object [] {args};
main.invoke(null,arguments);
}
}


解决方案

I不认为这个工作可以从构建阶段完成(我很乐意错误,然后看到另一个答案) -

看来这里还有另一个答案< Java:通过运行时修改系统属性它说在你的最后写一个包装主要方法,所以你可以传递你需要的属性,不知道它有多好。


i am using a javafx application and we developed a gradle build system for this application. The jar file can be created with the following gradle task:

    task fatJar(type: Jar) {
manifest {
    attributes 'Main-Class': 'myProject'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' 
with jar

}

This works so far - the only problem is that we want to use the virtual keyboard (javafx) and therefore we need to set the following system properties:

     systemProperty 'com.sun.javafx.isEmbedded', 'true' 
     systemProperty 'com.sun.javafx.touch', 'true'       
     systemProperty 'com.sun.javafx.virtualKeyboard', 'javafx' 

Can i set this properties in the gradle build or is it necessary to start the application with

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

best regards

__________________________________-

The solution (big thanks to Frederic Henri :-)) is to write a wrapper class like

public class AppWrapper 
{   
    public static void main(String[] args) throws Exception 
    {  
        Class<?> app = Class.forName("myProject");         
        Method main = app.getDeclaredMethod("main", String[].class);     
        System.setProperty("com.sun.javafx.isEmbedded", "true"); 
        System.setProperty("com.sun.javafx.touch", "true");          
        System.setProperty("com.sun.javafx.virtualKeyboard", "javafx");     
        Object[] arguments = new Object[]{args};
        main.invoke(null, arguments);
    }
}

解决方案

I dont think this job can be done from the build phase (I'd be happy to be wrong and see another answer though) -

It seems there is another answer here Java: Modify System properties via runtime where it says to write a wrapper around your final main method and so you can pass the properties you need, not sure how good it is though.

这篇关于针对javafx应用程序的Gradle构建:虚拟键盘由于缺少System属性而无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆