Description of the problem
I am trying to run a simple JavaFX application as part of a virtualized OS X installation without success. When run on an OS X host system, everything works as expected.
After my research, others also stumbled upon this problem, but none of the proposed solutions seem to work:
- Using VirtualBox instead of VMware Fusion as a virtualization tool because "VMware is not a certified hypervisor" (see this question and the official specifications )
- I activated / deactivated 3D hardware acceleration support in the virtual machine settings.
My best approach so far has been to get the Java virtual machine to replace PRISM hardware 3D rendering with the PRISM software rendering engine (using -Dprism.order=sw , see this question ).
When using the hardware rendering engine, the JafaFX application crashes. When using the software rendering engine, the JavaFX application starts normally, but the interface elements do not appear at all.
I use the JavaFX “Hello World” application, which is generated by IntelliJ IDEA when selecting “New Project ...” → “Java FX Application”, plus adding a simple text label (see code below).
To start the JavaFX application from the command line, I call:
java -Dprism.order=sw -jar path/to/JavaFXApp.jar
Error message
The only error recorded on the JVM command line (even in verbose mode) is
CGLCreateContext error: 10002
This error is not logged on successful startup on the host system.
My settings
- IntelliJ IDEA 14.1.1
- JDK 1.8.0_40
- OS X 10.9.5 (host system)
- OS X 10.10.3 (guest OS)
- Vmware Fusion Professional 7.1.1
- VirtualBox 4.3.26
Code example
Main.java
package sample; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception{ Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); primaryStage.setTitle("Hello World"); primaryStage.setScene(new Scene(root, 300, 275)); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Controller.java
package sample; public class Controller { }
sample.fxml
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.control.Label?> <GridPane fx:controller="sample.Controller" xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10"> <children> <Label text="This is a 'javafx.scene.control.Label'" /> </children> </GridPane>