Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downloaded JDK 17 but project is using Java 11?

I am new to Java and am a bit confused about how this is working/how I should be working. I am using intellij and a project that I am working on its pom.xml has:

<java.version>11</java.version>
<maven.compiler.source>$(java.version)</maven.compiler.source>
<maven.compiler.target>$(java.version)</maven.compiler.target>

When I go into the project structure on intellij the module is using language level 11.

on my computer I just downloaded the newest JDK (17)?

Does this cause issues working like this? Should I only be using a JDK that is associated with the version I am working?

I have not had any issues... but I am afraid my dependencies might be different than the ones I should be using...or the the build will be different if someone else is using another jdk.

like image 884
Jack Trainer Avatar asked Sep 16 '25 17:09

Jack Trainer


1 Answers

The JDK version specified in the pom.xml specifies what source and target version is passed to javac. This specifies what system libraries and language features can be used.

The language level from IntelliJ matches this.

The installed JDK is the program (or set of programs) used for compiling and running the application.

Java allows to use a newer JDK to compile programs for older (source/target/release) versions.

The produced class files (bytecode) should be the same no matter what JDK version you use as long as the target/release version (specified in the pom.xml/language level in IntelliJ) is the same.

Furthermore, Java is (almost completely) backwards compatible. When writing code for an old Java version, it will likely also work in newer Java versions.

like image 113
dan1st Avatar answered Sep 18 '25 05:09

dan1st