. Advertisement .
. Advertisement .
The error: “Could not target platform: ‘Java SE 8’ using tool chain: ‘JDK 7 (1.7)’” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
When dose this problem appear?
IntelliJ IDEA supports a fully-functional integration with Gradle that allows you to automate the building process. You can start a new Gradle project, open it, and connect an existing one or work with multiple related projects simultaneously, and control the projects.
You can create a Gradle project and store it in the WSL environment or open it from the WSL file system. When attempting to import a Gradle project into Intellij Idea, you might get the following issue.
Could not target platform: 'Java SE 8' using tool chain: 'JDK 7 (1.7)'
How To Solve The Error: “Could not target platform: ‘Java SE 8’ using tool chain: ‘JDK 7 (1.7)’”?
Approach 1: Modify Gradle JVM
Simply change the Gradle JVM.
- To begin with, go to File.
- Choose Setting.
- Then comes Build, Execution, and Deployment.
- Choose Build Tools.
- Then select Gradle.
- Gradle JVM should be updated to version 1.8.
- Run the gradle task again now.
- Now, you have solved your problem.
Approach 2: Choose the correct version
Intellij IDEA => Preferences => Build, Execution, Deployment => Build Tools => Gradle => Gradle JVM => Choose the correct version.
Next, you must include the following line in your build.gradle dependencies.
compileOnly group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
Approach 3: Import theGradle project.
These are the steps:
- Switch from local Gradle distrib to Intellij Idea Gradle Wrapper (gradle-2.14).
- Point system variable
JAVA_HOMEto JDK 8 (it was 7th previously) as you can figure out by experiments that Gradle Wrapper could process the project with JDK 8 only.
- Remove previously manually created file gradle.properties (with
org.gradle.java.homevariable) in windows user .gradle directory.
Approach 4: Set to java 8
sourceCompatibility = 1.8 targetCompatibility = 1.8
Approach 5: Switching it to 1.7
Switching these to 1.7 solved the problem and keeping JAVA_HOME pointing to the installed JDK-7
sourceCompatibility = 1.7 targetCompatibility = 1.7
Approach 6: The scientific method
The scientific method is that method that is open for argumentation and deals on common denominators. Below is the steps can help you alot:
sourceCompatibility = JavaVersion.toVersion('11')
targetCompatibility = JavaVersion.toVersion('11')
sourceCompatibility = JavaVersion.toVersion('8')
targetCompatibility = JavaVersion.toVersion('8')
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “Could not target platform: ‘Java SE 8’ using tool chain: ‘JDK 7 (1.7)’” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Leave a comment