我有一个JavaFx (maven) 项目,使用以下Intellij运行配置:
这个配置在Windows上表现很好,但在OSx上会导致以下错误:
我在谷歌上搜索了这个错误,看起来似乎与缺少JavaFx库有关。
但是,如果我执行以下运行配置:
执行
(mvn) clean javafx:run
这个配置在Windows上表现很好,但在OSx上会导致以下错误:
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:280)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:243)
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
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:94)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
at java.base/java.lang.Thread.run(Thread.java:834)
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:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: No toolkit found
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
... 5 more
我在谷歌上搜索了这个错误,看起来似乎与缺少JavaFx库有关。
但是,如果我执行以下运行配置:
(mvn) clean package
然后它会构建一个适当的JAR文件,我可以在我的Mac上执行。
所以,我怀疑这可能是与JavaFX IntelliJ插件相关的问题,但我不确定如何解决这个问题(如果确实是这个问题)。
我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.6</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12.0.2</version>
</dependency>
<!-- the reason for having these dependency for all classifiers is here: https://dev59.com/BVQJ5IYBdhLWcg3w_7O7#52654791-->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>12.0.2</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>12.0.2</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>12.0.2</version>
<classifier>mac</classifier>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.fxml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<executions>
<execution>
<!-- Default configuration for running -->
<id>default-cli</id>
<configuration>
<mainClass>com.app.MyApplication</mainClass>
</configuration>
</execution>
<execution>
<!-- Configuration for debugging -->
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005</option>
</options>
<mainClass>com.app.MyApplication</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.app.MainClass</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
执行
mvn clean -X javafx:run
后日志的最后一条记录为:Executing command line: [C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\jbr\bin\java.exe, --module-path, C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-base\12.0.2\javafx-base-12.0.2-win.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-base\12.0.2\javafx-base-12.0.2.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-controls\12.0.2\javafx-controls-12.0.2-win.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-controls\12.0.2\javafx-controls-12.0.2.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-fxml\12.0.2\javafx-fxml-12.0.2-win.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-fxml\12.0.2\javafx-fxml-12.0.2.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-graphics\12.0.2\javafx-graphics-12.0.2-linux.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-graphics\12.0.2\javafx-graphics-12.0.2-mac.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-graphics\12.0.2\javafx-graphics-12.0.2-win.jar
C:\Users\Vasiliy\.m2\repository\org\openjfx\javafx-graphics\12.0.2\javafx-graphics-12.0.2.jar, --add-modules, javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.graphics,javafx.graphics, -classpath, C:\Users\Vasiliy\projects\wellsense-annotator\target\classes
C:\Users\Vasiliy\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar
C:\Users\Vasiliy\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar
C:\Users\Vasiliy\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar
C:\Users\Vasiliy\.m2\repository\com\google\code\gson\gson\2.8.5\gson-2.8.5.jar
C:\Users\Vasiliy\.m2\repository\com\opencsv\opencsv\4.6\opencsv-4.6.jar
C:\Users\Vasiliy\.m2\repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar
C:\Users\Vasiliy\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar
C:\Users\Vasiliy\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar
C:\Users\Vasiliy\.m2\repository\org\apache\commons\commons-collections4\4.2\commons-collections4-4.2.jar
C:\Users\Vasiliy\.m2\repository\org\apache\commons\commons-lang3\3.8.1\commons-lang3-3.8.1.jar
C:\Users\Vasiliy\.m2\repository\org\apache\commons\commons-text\1.3\commons-text-1.3.jar
C:\Users\Vasiliy\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar, com.wellsensevu.MyApplication]
非常感谢您的帮助。
相关技术是IT技术。