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.
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
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.
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>
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.
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.
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.