简体   繁体   English

如何使 javaFX 在 Mac 中与 VSCode 一起使用?

[英]How do I make javaFX work with VSCode in Mac?

I am trying to make JavaFX work with VSCODE but I encounter this error;我试图让 JavaFX 与 VSCODE 一起工作,但我遇到了这个错误;

I have the latest java installed "openjdk 17.0.1 2021-10-19" and I am using the latest javaFx17.0.1.我安装了最新的 java “openjdk 17.0.1 2021-10-19”,我使用的是最新的 javaFx17.0.1。 I added all the references lib and added the vmArgs path file.我添加了所有引用库并添加了 vmArgs 路径文件。

I am using the base model macbookpro m1.我正在使用基础 model macbookpro m1。

This is my vmArgs path:这是我的 vmArgs 路径:

"vmArgs": "--module-path /Users/jeffreygrospe/Downloads/javafx-sdk-17.0.1/lib --add-modules javafx.controls,javafx.fxml",

This is what inside the javafx lib folder:这是 javafx lib 文件夹中的内容:

javafx-swt.jar      javafx.web.jar      libjfxmedia.dylib
javafx.base.jar     libdecora_sse.dylib libjfxmedia_avf.dylib
javafx.controls.jar libfxplugins.dylib  libjfxwebkit.dylib
javafx.fxml.jar     libglass.dylib      libprism_common.dylib
javafx.graphics.jar libglib-lite.dylib  libprism_es2.dylib
javafx.media.jar    libgstreamer-lite.dylib libprism_sw.dylib
javafx.properties   libjavafx_font.dylib
javafx.swing.jar    libjavafx_iio.dylib
Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:254)
        at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:264)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
        at java.base/java.lang.Thread.run(Thread.java:833)
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
Caused by: java.lang.RuntimeException: No toolkit found
        at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:276)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
        ... 5 more

I finally manage to have JavaFX work with VScode on Mac m1.我终于设法让 JavaFX 在 Mac m1 上与 VScode 一起工作。 With enough research, it was the JDK that was causing the error.经过足够的研究,导致错误的是 JDK。 I use "Liberica JDK 17.0.1+12, LTS" it works just fine.我使用“Liberica JDK 17.0.1+12,LTS”,它工作得很好。

Another option is to use Azul jdk v17.另一种选择是使用 Azul jdk v17。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM