Problem Description
I've been trying to run a simple JavaFX application within a virtualized OS X installation, without success. When launched natively on the OS X host system, everything works as expected.
Following my research, others have stumbled upon this issue as well, but none of the suggested solutions seem to work:
- Using VirtualBox instead of VMware Fusion as virtualizer tool, because "VMware is not a certified hypervisor" (see this question and the official specs)
- I've activated/deactivated 3D hardware acceleration support in the virtual machine's settings.
My best approach so far was to prompt the Java VM to replace the PRISM hardware 3D render engine with the PRISM software render engine (by using -Dprism.order=sw
, see this question).
When using the hardware render engine, the JafaFX application crashes. When using the software render engine, the JavaFX application starts up fine, but no UI elements are displayed at all.
I'm using the JavaFX "Hello World" application, that gets generated by IntelliJ IDEA when choosing "New Project..." -> "Java FX Application", plus adding a simple text label (see code below).
To run the JavaFX application from the command-line, I'm calling:
java -Dprism.order=sw -jar path/to/JavaFXApp.jar
Error Message
The only error logged to the command-line by the JVM (even in verbose mode) is
CGLCreateContext error: 10002
This error is not logged when run successfully on the host system.
My Specs
- IntelliJ IDEA 14.1.1
- JDK 1.8.0_40
- OS X 10.9.5 (host OS)
- OS X 10.10.3 (guest OS)
- Vmware Fusion Professional 7.1.1
- VirtualBox 4.3.26
Sample Code
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>