Reputation: 289
I have created a JavaFX application in IntelliJ14.14 that will use the JavaFX Virtual Keyboard. I have add the following properties in 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 run the app from IntelliJ everything works fine. The virtual keyboard works perfectly.
But when I generate the Jar file of the application from Build -> Build Artifacts... -> Build and execute it, the keyboard never shows because the VM options are not being set.
It's something I'm missing...?
Thanks in advance...
EDIT
I have found a way to make this work, running the file from the cmd with this command:
java -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard="javafx" -Dcom.sun.javafx.touch=true -jar myApp.jar
However I want to make this just executing the Jar file...
EDIT
There is another nearby way to accomplish what I want...
Create a file .bat in the same folder of the jar and put in it:
start javaw -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard="javafx" -Dcom.sun.javafx.touch=true -jar myApp.jar
So when tha .bat file is executed and the jar file is started, the system properties are loaded correctly...
Upvotes: 4
Views: 1220
Reputation: 5012
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
//...
//...
}
}
Upvotes: 2