Programming

‘Error Java Javactask Source Release 8 Requires Target Release 1.8’ – Explained and Fixed

If you use IntelliJ IDEA to write the Java code, then you might have faced the error java javactask source release 8 requires target release 1.8 issue. This error message occurs when the written code can’t find the corresponding JDK compiler.

error:java: javacTask: source release 8 requires target release 1.8 (Main Image)

Since this error message mostly occurs in IntelliJ IDEA, therefore, this error message is also known as IntelliJ IDEA error:java: javacTask: source release 8 requires target release 1.8. Anyway, if you’re also facing this error code, then let’s fix this.

Why Does This Error Message Occur?

  • If the code in IntelliJ IDEA is written on the basis of JDK 1.8 and when the code couldn’t find the corresponding JDK compiler, people face this error message.
  • This error message also occurs when the user enters the incorrect Java compiler information in the code.

How to Fix the Javactask Source Release Error?

Unlike the length of this error message, it is easier to fix it. In fact, there are two methods to fix this error code. One is for non-Maven users and the other one is for Apache Maven users. So, without any further delay, let’s get to the solutions.

Solution 1: Fixing by Changing Project Bytecode Version via ‘Settings’ Menu

verified solution

In this solution, we’ll go through the settings of the IntelliJ IDEA to fix this error message.

  1. First, you’ll go to the ‘File’ menu in the Menu bar.

    Accessing the ‘File’ option in the menu bar
  2. Then, you’ll choose the ‘Settings’ option.

    Choosing the ‘Settings’ option in the ‘File’ menu

Note: You can also open the ‘Settings’ by pressing ‘Ctrl + Alt + S’ keys

  1. After that, you’ll select the ‘Build, Execution, Deployment’ option and expand it.
  2. Then, inside the ‘Build, Execution, Deployment’ option, you’ll expand the ‘Compiler’ option and from the drop-down list, you’ll choose the ‘Java Compiler’ option.

    Choosing the ‘Build, Execution, Deployment’ < ‘Compiler’ < ‘Java Compiler’ options
  3. Inside the ‘Java Compiler’ window, you’ll change the ‘Project bytecode version:’ to ‘1.8’ and then, you’ll ‘Apply’ the settings.

    Changing the ‘Project bytecode version’ to ‘1.8’

This solution is the easiest and most successful way to fix this error code. However, if you’re an Apache Maven user, then try the next solution.

Solution 2:  Adding the Compiler Plug-in in the ‘pom.xml’ File

For People Using ‘Apache Maven’

verified solution

If you’re a programming nerd and you want to perform this entire operation via coding or you’re using ‘Apache Maven, then this solution is for you.

Here, we’ll add the compiler plug-in in the ‘pom.xml’ file, which you’ll find under the top-level project node.

  1. Once you’ve accessed the ‘pom.xml’ file, then, you’ll copy and paste the following code into that file.
<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<configuration>

<source>1.8</source>

<target>1.8</target>

</configuration>

</plugin>

</plugins>

</build>
  1. After the code modification, you’ll select the ‘Reimport’ option in the Maven menu of IntelliJ IDEA.
  2. Then, you’ll re-import the project settings.
  3. After that, the tool will automatically apply the correct settings.

Talha Saeed

I am a BSCS graduate and a technology nerd who now loves working and writing about computers and other tech-related stuff. In my free time, I like watching Netflix and playing Cricket 22 and The Witcher 3 (Wild Hunt).
Back to top button