我的系统:
我想用maven启动我的JavaFX应用程序。为此,我在插件菜单中使用javafx:run按钮。
然后,我得到了关于我的jdk的错误,在一个太低的级别上(它告诉我我试图用我的jdk-8来执行我的主要方法),这不是真的,因为每个jdk-specification都设置为jdk-17。
请不要给我发任何关于其他帖子的链接。我已经试过了,那里的步骤对我没有效果。
,这是我得到的错误
Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0- Yes I already tried to change IntelliJs jdks, the JAVA\_HOME variable and the run configs of maven itself。
,这是我的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>
<groupId>groupId</groupId>
<artifactId>M226a_miniproject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>17</release>
<verbose>true</verbose>
<fork>true</fork>
<executable>C:/Users/[user.name]/.jdks/openjdk-17/bin/javac</executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>ch.package.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>17.0.0.1</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-graphics -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>17.0.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.0.1</version>
</dependency>
</dependencies>
</project>也许第二个插件中的<version>0.0.8</version>有什么问题吗?
另外: JRE不识别类文件的错误是没有意义的,因为甚至我的maven也在使用我的jdk-17的自定义路径。
编辑:更新的pom.xml
发布于 2021-10-27 07:58:19
(修复了我的Ubuntu20.04机器上的问题,但错误是相同的)
问题是,我只将jdk-17下载到IntelliJ中。
我只是通过运行sudo apt install openjdk-17-jdk来安装jdk-17,它安装jdk和
sudo update-alternatives --config java,它更新最新jdk的intex (我认为)。
最后一步是重新启动IntelliJ,我准备好了。
https://stackoverflow.com/questions/69676622
复制相似问题