8

I created a demo JavaFX application to demonstrate cross-platform applications and then ran it on various platforms (i.e. Windows, Linux, and Mac).

package crossplatformdemo;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Tooltip;
import javafx.scene.effect.Effect;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class CrossPlatformDemo extends Application
{
    public static void main(String[] args)
    {
        launch(args);
    }

    @Override
    public void start(Stage Window) throws Exception
    {
        StackPane Layout = new StackPane(); 
        Scene scene = new Scene(Layout,400,200);
        Button button = new Button("Click Here");
        
        //button
        {
            button.setTooltip(new Tooltip("Nothing Will Happen"));
            Layout.getChildren().add(button);
        }
        
        //Window
        {
            Window.setResizable(false);
            Window.setTitle("Cross Platform Demo");
            Window.setScene(scene);
            Window.show();
        }
        
    }
    
}

Works perfectly fine on:-

  1. Windows 10

    Windows 10

  2. Ubuntu 16.04.3 LTS

    Demo Application Running on Ubuntu 16.04.3 LTS

But show a blank Application window on Mac OS. Demo Application Running on Mac OS High Sierra

along with the error.

2018-01-02 CGLChoosePixe1Format error: 10002
2018-01-02 CGLCreateContext error: 10002

How can I run it on Mac OS?

Running Java 8, Ubuntu on VirtualBox, Mac OS High Sierra on VMWare. Used physical windows machine.

Edit: Following suggestions, tried running the app with and without 3D acceleration, and reinstalling VMware Tools. It made no difference.

verbose output

Rachits-Mac:dist rachit$ java -Dprism.verbose=true -jar CrossPlatformDemo.jar

Prism pipeline init order: es2 sw 
Using native-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.es2.ES2Pipeline
Loading ES2 native library ... prism_es2
    succeeded.
GLFactory using com.sun.prism.es2.MacGLFactory
(X) Got class = class com.sun.prism.es2.ES2Pipeline
GraphicsPipeline.createPipeline: error initializing pipeline com.sun.prism.es2.ES2Pipeline
*** Fallback to Prism SW pipeline
Prism pipeline name = com.sun.prism.sw.SWPipeline
(X) Got class = class com.sun.prism.sw.SWPipeline
Initialized prism pipeline: com.sun.prism.sw.SWPipeline
vsync: true vpipe: false
2018-01-02 16:58:51.904 java[561:8835] CGLChoosePixelFormat error: 10002
    2018-01-02 16:58:51.904 java[561:8835] CGLCreateContext error: 10002
Loading Prism common native library ...
    succeeded.
QuantumRenderer: shutdown

Tried with Software Emulation

Rachits-Mac:dist rachit$ java -Dprism.order=sw -Dprism.verbose=true -jar CrossPlatformDemo.jar

Prism pipeline init order: sw 
Using native-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
*** Fallback to Prism SW pipeline
Prism pipeline name = com.sun.prism.sw.SWPipeline
(X) Got class = class com.sun.prism.sw.SWPipeline
Initialized prism pipeline: com.sun.prism.sw.SWPipeline
vsync: true vpipe: false
2018-01-02 16:59:43.619 java[564:9126] CGLChoosePixelFormat error: 10002
2018-01-02 16:59:43.619 java[564:9126] CGLCreateContext error: 10002
Loading Prism common native library ...
    succeeded.
QuantumRenderer: shutdown

The app crashed when using "j2d" and had to force quit.

Rachits-Mac:dist rachit$ java -Dprism.order=j2d -Dprism.verbose=true -jar CrossPlatformDemo.jar
Prism pipeline init order: j2d 
Using native-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
WARNING: The prism-j2d pipeline should not be used as the software
fallback pipeline. It is no longer tested nor intended to be used for
on-screen rendering. Please use the prism-sw pipeline instead by setting the "prism.order" system property to "sw" rather than "j2d".
*** Fallback to Prism SW pipeline
Prism pipeline name = com.sun.prism.j2d.J2DPipeline
(X) Got class = class com.sun.prism.j2d.J2DPipeline
Initialized prism pipeline: com.sun.prism.j2d.J2DPipeline
vsync: true vpipe: false
2018-01-02 17:00:34.549 java[570:9763] CGLChoosePixelFormat error: 10002
2018-01-02 17:00:34.549 java[570:9763] CGLCreateContext error: 10002
QuantumRenderer: shutdown

Here's version info if needed:-

  • Java Runtime Environment: build 1.8.0_152-b16.(Tried with Java 9, same behavior).
  • MAC: Darwin Kernel Version 17.0.0
Rachit Chauhan
  • 121
  • 1
  • 7
  • Your code works fine on my Mac. Can you give more details about the platform (exact JDK version, Mac OS X version, etc)? – James_D Jan 01 '18 at 20:12
  • 4
    Off topic (a little): your code will be much easier for others to read (and so easier for them to help) if you use [standard naming conventions](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Java), and also standard layout (the braces inside the start method seem to serve no purpose). – James_D Jan 01 '18 at 20:17
  • 2
    Also works fine on my MacOS 10.13.2 High-Sierra. I think your OpenGL of your virtual machine might be too low of a version or just unsupported.. According to this: http://mail.openjdk.java.net/pipermail/openjfx-dev/2016-April/018974.html VMWare isn't supported very well.. and: https://communities.vmware.com/thread/528682 – Brandon Jan 01 '18 at 20:19
  • 1
    Can you try disabling hardware acceleration as described here: https://stackoverflow.com/questions/18754803/how-to-disable-or-bypass-hardware-graphics-accelerationprism-in-javafx ? I think the problem is that JavaFX tries to use hardware acceleration but vmware doesn't support that (https://kb.vmware.com/s/article/1032440) – sknt Jan 02 '18 at 00:46
  • @James_D I have added version information for Mac OS and JDK long with verbose output and thanks for your advice about naming conventions. – Rachit Chauhan Jan 04 '18 at 06:28
  • @Skynet I tried running the application with and without 3D acceleration, It does not seem to work anyway. – Rachit Chauhan Jan 04 '18 at 06:33
  • 1
    I'm having a similar problem. Did you have any luck with this? – Saeid Nourian Feb 21 '20 at 02:22
  • @SaeidNourian. We couldn't find any solution to this issue. Looks like you'll need a physical mac. – Rachit Chauhan Feb 22 '20 at 08:31
  • Thanks @RachitChauhan. I was afraid of that! oh well – Saeid Nourian Feb 22 '20 at 23:30
  • 4
    https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8235627 This looks like it is exactly this error and it was fixed in openjfx14. I have the same problem and I couldn't find another workaround than using a physical machine... – KnechtRootrecht Apr 07 '20 at 13:22

0 Answers0