Fix the Maven Compliance Specified is JDK 1.5 not JRE 1.8 Er |Video upload date:  · Duration: PT3M8S  · Language: EN

Quick guide to fix Maven error saying compliance specified is JDK 1.5 not JRE 1.8 by aligning pom compiler properties Java home and IDE settings

Why Maven keeps whispering about Java 1.5

Maven sometimes acts like a nostalgic archaeologist and insists your code was born in Java 1.5 even though you fed it a modern JDK 1.8. The usual suspects are mismatched runtime, a PATH or JAVA_HOME that points to a JRE instead of a JDK, or an absent maven compiler configuration in the project pom.xml. This guide shows you the quick checks and fixes so Maven stops time traveling and compiles with Java 1.8 instead.

Quick checklist to stop the time travel

  • Verify the Java runtime that Maven sees
  • Make sure JAVA_HOME points to a real JDK and not a scaled down JRE
  • Define Java level in pom.xml so Maven does not guess wrong
  • Set the IDE project SDK and language level to match the JDK
  • Do a clean build and watch for any lingering 1.5 mentions

Step 1 Verify the runtime

Open a terminal and run the usual command to see the Java runtime. If the output looks ancient or cryptic you will know why Maven is upset.

java -version

Also check what Maven itself is using. Run a standard Maven command from the project root and watch the header for the JVM info.

mvn -v

Step 2 Make sure JAVA_HOME is a JDK

On Unix style shells run

echo $JAVA_HOME

On Windows run

echo %JAVA_HOME%

Confirm the path points at a JDK 1.8 installation and not a JRE. A JDK directory will have the compiler tools and a lib tools jar. If JAVA_HOME points to a JRE update it so Maven can find the Java compiler.

Step 3 Declare the Java level in pom.xml

Stop relying on Maven psychic powers. Add explicit properties so Maven uses the right source and target levels. Put this in the project pom xml within the properties element.

<properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>

If the project still complains add an explicit maven compiler plugin block. That tells Maven the language level to use during compilation so it does not fall back to legacy defaults.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.8.1</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
      </configuration>
    </plugin>
  </plugins>
</build>

Step 4 Align the IDE SDK and project language level

IDEs are great until they are not. Open your IDE project settings and verify both the project SDK and the language level are set to JDK 1.8. IntelliJ users check Project Structure and set the Project SDK and Project language level. Eclipse users check Java Build Path and Installed JREs and set the project compliance to 1.8. Some editors run the IDE on a bundled JRE while Maven runs using your system JAVA_HOME. Make them agree and the peace talks will work.

Step 5 Clean build and watch the logs

Run a full clean build so Maven picks up the config changes. The classic command works just fine.

mvn clean install

Read the compiler output. If you still see 1.5 mentioned track down leftover settings in parent poms, profiles, or legacy toolchain files. The usual culprits are parent pom properties or CI environment variables overriding your local settings.

Extra tips that do not require witchcraft

  • Prefer defining Java level in one place using pom properties so Maven and CI do not disagree
  • If using a CI server verify the agent JAVA_HOME and toolchain settings match your local JDK
  • For multi module projects check parent pom and submodule poms for conflicting values

Wrap up with a little sarcasm

Maven does not actually want to sabotage your life. It just follows rules and defaults like a very stubborn intern. Give it clear instructions in pom.xml and point JAVA_HOME at a real JDK and the compliance mismatch will vanish. If it still acts up then yes blame the legacy configuration and move on with your modern Java 1.8 life.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.