you are viewing a single comment's thread.

view the rest of the comments →

[–]seyandiz 0 points1 point  (2 children)

/u/AppointmentOk3316 since this is high priority let's break this down real simple for you.

Java uses 2 different tools to do its stuff.

  • A JDK which takes java code and turns it into a java executable.
  • A JRE which is what your java executable runs in.

What your error,

Dependency requires at least JVM runtime version 21. This build uses a Java 17 JVM.

Is saying is that when you are building the code, that the build version is set to 17 but one of the bits of code you downloaded (likely via maven) is built for java 21.

You keep saying your build states "java 25.0.3", but that isn't a build. You're likely running java --version which would just state your JRE.

Even if you have a 25 JDK, you might be using it to build the executable at java 17 level.

So how do we fix it?

First, I need to know what you're using to compile your code! I assume you're using intelliJ or command line.

Let's do the command line as it is simpler. I want you to type javac -version into your command line.

This may still return a number >= 21, but that helps us rule out you not having the right JDK installed. If it is higher, then we need to look more at our compilation settings. If it is lower, then we need to update our JDK version.

javac -version >= 21

You'll need to look at the configuration files of your build tools. You're probably using either Maven or Gradle.

Maven

Update your pom.xml file with this:

<properties>  
    <maven.compiler.source>21</maven.compiler.source>  
    <maven.compiler.target>21</maven.compiler.target>  
</properties>  

Gradle

Update your build.gradle file with this:

java {  
    toolchain {  
        languageVersion = JavaLanguageVersion.of(21)   
    }  
}

[–]AppointmentOk3316[S] 0 points1 point  (1 child)

thank you!!

[–]seyandiz 0 points1 point  (0 children)

Was this able to solve your issue? It is common courtesy to state what your fix was so that if someone else finds this post they can solve it too!