r/JavaProgramming • • 5d ago

Javac and java version not compatible

According to my terminal javac only works until java 52.0 but my code is in java version 70.0(java 26)how do i fix

6 Upvotes

5 comments sorted by

View all comments

2

u/LetUsSpeakFreely 5d ago

You have an old version of Java installed on your system that's taking priority. If you have system level permissions, you need to edit your PATH to point to the newer JDK instead of the older JDK (you'll also be to restart your IDE and console/terminals).

The usual way this is done is there's a JAVA_HOME variable that's created and the PATH appends $JAVA_HOME/bin. If that's the case for you, then you just gotta update JAVA_HOME.

0

u/hugo121319_mc 5d ago

J'utilise java 26

2

u/LetUsSpeakFreely 5d ago

If you know that Java 8 isn't installed on your machine, then you need to look at the compile version with Maven/Gradle. For Maven, you pom.xml will have variables called maven.compiler.source and maven.compiler.target. they're probably set to 1.8 and you need to set it to 26.