Error:java: javacTask: source release 8 requires target release 1.8

This error message usually indicates that you are trying to compile your Java code with a version of the javac compiler that is not compatible with the version of the Java language that your code is written in.

To fix this error, you will need to ensure that you are using a version of the javac compiler that is compatible with the version of the Java language that your code is written in.

To do this, you will need to set the JAVA_HOME environment variable to point to the directory where your desired version of the Java Development Kit (JDK) is installed. You can then use the java and javac commands from the bin directory within the JDK installation directory to compile and run your Java code.

For example, if your code is written in Java 8 and you have the JDK 8 installation in the /usr/lib/jvm/jdk1.8.0 directory, you can set the JAVA_HOME environment variable by adding the following line to your ~/.bashrc file:

export JAVA_HOME="/usr/lib/jvm/jdk1.8.0"

You can then use the java and javac commands from the bin directory within the JDK installation directory to compile and run your Java code:

$ JAVA_HOME/bin/javac MyClass.java
$ JAVA_HOME/bin/java MyClass