My System:
- Has multiple jdks (1.8, 16, 17)
- Has IntelliJ's Maven
- Is a windows 10 machine
I want to start my JavaFX app with maven. For that I use the javafx:run
button inside of the Plugins menu.
Then I get errors about my jdk
, being on a too-low-level (It's telling me I try to execute my Main method with my jdk-8
), which is not true, as every single jdk-specification
is set to jdk-17
.
Please don't send me any links about other posts. I have already tried those and the steps there did not work out for me.
This is the error I get
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
Sometimes I also get an error from maven, telling me there is no JavaFX version 17 in the maven repository (but the maven repo of my workplace). Is there a way to change my maven-repo to the default maven website?
This is my 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>
Maybe somethings wrong with the <version>0.0.8</version>
in the second plugin?
Also: The error about the JRE not recognizing the class file does make zero sense, as even my maven is using a custom path to my jdk-17.
Edit: Updated pom.xml
CodePudding user response:
(Fixed the problem on my Ubuntu 20.04 machine, but the error was the same)
The problem was, that I only had downloaded a jdk-17 into IntelliJ.
I simply installed the jdk-17 by running sudo apt install openjdk-17-jdk
, which installs the jdk and
sudo update-alternatives --config java
, which updates the intex of the newest jdk (i think).
The last step was to restart IntelliJ and I was good to go.