2

Today I've started to get this warning in the console, when I try to compile my programs with javac:

warning: Blabla.class: major version 52 is newer than 51, the highest major version supported by this compiler.

it is recommended that the compiler be upgraded.

But how can I do that?

PS. command javac -version returns 1.7.0_85, while java -version returns 1.8.0_66. I do not know how this mixture has happened.

Jacobian
  • 194
  • 1
  • 1
  • 12

1 Answers1

5

You have more than one Java version installed and you are using different versions for java and javac. javac -version returns 1.7.0_85, while java -version returns 1.8.0_66. This means that javaccreates bytecode for Java 7 and you try to compile a version for Java 8.

Execute

sudo update-alternatives --config javac

and select Java 8 to solve your problem.

cl-netbox
  • 30,845
  • 7
  • 93
  • 131
A.B.
  • 89,123
  • 21
  • 245
  • 323
  • It was giving me an error that I had no alternative javac available. I was able to solve the issue by following the marked answer of [this question](https://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk). – Sufian Mar 29 '21 at 11:58