Cannot build Java 8 Project with system Java version being latest [RESOLVED]

已回答

Hey!

I'm having an issue trying to build my Java 8 project which uses JavaFX. I did not have this problem originally when I had Java 8 installed on my system, but for another project I need to use the latest version of Java, so I am now using Java version 22.0.1. Ever since updating, I can no longer properly build my Java 8 project… I do not want to change the Java version on my computer, but would like my Java 8 project within IntelliJ to be built with Java 8 and ran with it as well. I have provided screenshots below of my current settings trying to accomplish this. Any help is appreciated. Thanks!

 

When I try to build the project, I get the following error:

 

0

For some interesting reason, this issue only happens when making it a JavaFX artifact… The artifact will run fine as a JAR file from modules with dependencies. When using a JavaFX artifact, you'll encounter the above issues no matter all the settings you turn to Java 8. Hoping this can be fixed in a future release or at least further explained by the JetBrains team? Thanks!

0

Hello,
 
It seems you are facing the problem https://youtrack.jetbrains.com/issue/IDEA-351703/Error-building-JavaFX-artifact-in-IntelliJ-IDEA
 
According to our developer's advice:
 

Please use Maven task instead, since your project is Maven based.

https://github.com/openjfx/javafx-maven-plugin does that via javafx:jlink goal

This plugin is included by default in new Maven project for JavaFX

Modern JavaFX application cannot be distributed as JAR nowadays, you have to build a folder with JRE and application executables and this is what javafx:jlink does.

mvn javafx:jlink

target/image/bin/java -m hellofx/org.openjfx.App

PowerShell

 

This is where the result application will reside target/image

 
The Maven/Gradle is the suggested way to dev a JavaFX project.
 
You may use these two maven goals to package the project:
jar -> a jar file created
jlink -> a minimal distribution app.zip is created with JavaFx bundled, which can be run be unzipping and exectute the bin/app script.

 

 
Please check if the above steps help.
 

0

请先登录再写评论。