我开发了这个Demo JavaFX应用程序来演示跨平台应用程序的工作。所以我编写并编译了这个Java代码并在Windows,Linux,Mac OS上运行它。
在Windows 10上运行的演示应用程序
在Ubuntu 16.04.3 LTS上运行的演示应用程序
在Zorin OS 12上运行的演示应用程序
它在Windows和Linux上运行得非常好。但是在Mac OS上显示一个空白的应用程序窗口。
在Mac OS High Sierra上运行的演示应用程序
以及此错误消息。我不明白这个错误信息
终端错误消息
如何在Mac OS上运行此应用程序?
我使用Java 8.在Netbeans IDE上制作,我使用VirtualBox来运行Ubuntu,Zorin。二手VMWare for Mac OS High Sierra。使用我的物理机器进行Windows输出。
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();
}
}
}
编辑:按照您的建议后,我尝试使用和不使用3D加速,卸载和更新VMware Tools来运行应用程序 胸围仍显示空白窗口。
这是命令的详细信息
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
使用软件仿真验证了这一点
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
使用“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
演示应用程序必须被迫退出
Mac OS版本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
我的Java版
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
我甚至尝试过使用Java 9,但没有工作