8

I developed this Demo JavaFX application to demonstrate the working of cross-platform applications. So I wrote and compiled this Java Code and ran it on Windows, Linux, Mac OS.

Demo Application Running on Windows 10 Demo Application Running on Windows 10

Demo Application Running on Ubuntu 16.04.3 LTS Demo Application Running on Ubuntu 16.04.3 LTS

Demo Application Running on Zorin OS 12 Demo Application Running on Zorin OS 12

It works perfectly fine on Windows and Linux. But show a blank Application window on Mac OS.

Demo Application Running on Mac OS High Sierra Demo Application Running on Mac OS High Sierra

along with this error message. I don't understand this error message

Terminal Error Message Terminal Error Message

How can I run this application on Mac OS?

I used Java 8. I made this on Netbeans IDE, and I used VirtualBox to Run Ubuntu, Zorin. Used VMWare for Mac OS High Sierra. Used my physical machine for Windows Output.

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

    }

}

Edit: After following your advice, I tried running the app with and without 3D acceleration, Uninstalling and Updating VMware Tools but still shows the blank window.

Here is the verbose for command

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 this 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

App crashed after I used "j2d"

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

Demo App Had to be forced to quit

Demo App Had to be forced quit

Mac OS Version 10.13

Rachits-Mac:~ rachit$ uname -a
Darwin Rachits-Mac.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64

My Java Version

Rachits-Mac:~ rachit$ java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

Rachits-Mac:~ rachit$ javac -version
javac 1.8.0_152

I even tried this with Java 9, did not work

  • 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
  • 3
    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
  • 1
    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
  • 3
    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