intellij idea - Error java invalid source release 1.9
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
IntelliJ IDEA is a popular Integrated Development Environment (IDE) for Java development. However, developers may encounter the error message "java: invalid source release 1.9" during their workflow. This article explores the technical underpinnings of this error, its causes, and how to resolve it effectively.
Understanding the Error
The error "java: invalid source release 1.9" typically arises when there is a mismatch between the Java Development Kit (JDK) version specified in the project and the actual JDK version supported or installed on the system.
Java Versioning
Java source releases follow a specific version pattern. Java 9, officially released in September 2017, introduced several changes, such as modularization through Project Jigsaw. However, as development continues, not all newer Intellij IDEA versions or JDK installations maintain backward compatibility with older standards, including the support for 1.9 as a shorthand for Java 9 in certain contexts.
Common Causes
- Incorrect JDK Version: The project might be configured to use a JDK version that is not actually present or not compatible with the specified source version.
- Deprecated Source Level: As of more recent Java versions, specifying
1.9might not be recognized. Instead,9should be used explicitly for projects targeting Java 9.
Steps to Resolve the Error
Here are some approaches to resolving this error in IntelliJ IDEA:
1. Verify and Set Correct JDK Version
- Check Installed JDKs: Ensure that the required JDK version is installed on your system. You can check this through terminal commands:
- Configure IntelliJ IDEA:
- Go to
File>Project Structure>Project. - Under
Project SDK, select the appropriate JDK version. - Under
Project language level, make sure it matches the JDK's version (e.g., 9, not 1.9).
2. Update Module Settings
- Module Language Level: Navigate to
File>Project Structure>Modules. Confirm that theLanguage levelfor each module corresponds with the version of Java.
3. Update Build Tools (Maven/Gradle)
For projects managed by Maven or Gradle, ensure that their respective configuration files reference the correct Java version:
Maven
In pom.xml, update the maven-compiler-plugin configuration:
Gradle
Edit the build.gradle file to specify the correct Java version:
4. Reimport Project
After making configuration changes, it's sometimes necessary to reimport the project to ensure IntelliJ IDEA applies all changes:
- Right-click the project root in the Project view and select
Reload Project.
Troubleshooting and Tips
If issues persist, consider the following tips:
- Environment Variables: Double-check that your
JAVA_HOMEenvironment variable points to the correct JDK installation. - Plugin Conflicts: Disable any IntelliJ plugins that might interfere with Java configuration or build processes.
- IDE Updates: Ensure IntelliJ IDEA itself is up-to-date, as newer releases may fix underlying problems or improve compatibility with the latest JDKs.
Summary Table
| Key Aspect | Description |
| Error Message | java: invalid source release 1.9 |
| Common Causes | Incorrect JDK version, Deprecated source level usage |
| Resolution Steps | Verify JDK installation, Correct JDK setup in IntelliJ, Update build files |
| Configuration Files | Adjust Maven pom.xml and Gradle build.gradle |
| Common Commands | java -version, javac -version |
| Troubleshooting Tips | Check JAVA_HOME, Disable conflicting plugins, Update IntelliJ IDEA |
By ensuring that your project settings and system installations are aligned with the version requirements, you can effectively resolve the "java: invalid source release 1.9" error in IntelliJ IDEA, leading to a smoother Java development experience.
Related reading
- Intellij IDEA complains cannot resolve spring boot properties but they work fine
- Intellij IDEA, format all code in a project
- IntelliJ IDEA generating serialVersionUID
- Intellij Idea Importing Gradle project - getting JAVA_HOME not defined yet
- Intellij IDEA Java classes not auto compiling on save
- IntelliJ IDEA jump from interface to implementing class in Java
- IntelliJ IDEA with Junit 4.7 JUnit version 3.8 or later expected
- IntelliJ Initialization failed for ''https//start.spring.io'' Please check URL, network and proxy settings

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.