John M John M - 1 year ago 86
Java Question

Maven compile error (asking for a higher JDK version)

I made a new project today and wanted to compile with Maven (I'm running it on IntelliJ). Made sure to change the JDK level to 1.8, which is what I currently use, tried to compile and I'm getting a lot of exceptions asking me to use the "-source 8" argument since the default one is 1.5, and I'm using features of newer JDK versions.

I haven't been using IntelliJ for a long time, could anyone please tell me how to change these Maven compile arguments or how to solve this issue?

Answer Source

You add this to your pom.xml

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

see: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download