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