title: Configure Maven to allow a range of JREs
body: <p>I am teaching a 2nd semester Java course, and I am trying to set up a <em>simple</em> Maven project that will will run in any student's environment (Windows/Mac/Linux, IntelliJ/VS Code/Eclipse,  any version of Java 8 or above) without complaining. Because this is only a second semester programming course, I want <code>pom.xml</code> to be as simple as possible.  The project need only be a couple of Java source files and a couple of test files.</p>
  
  <p>The current <code>pom.xml</code> is below.  It works, but Visual Studio Code on MacOS with Java 8 generates the following warnings:</p>
  
  <ul>
  <li>Build path specifies execution environment J2SE-1.5. There are no
  JREs installed in the workspace that are strictly compatible with
  this environment.  </li>
  <li>The compiler compliance specified is 1.5 but a JRE
  1.8 is used</li>
  </ul>
  
  <p>I can fix the problem by adding these lines:</p>
  
  <pre><code>  &lt;properties&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
    &lt;/properties&gt;
  </code></pre>
  
  <p>But, won't that cause warnings or errors for students with different Java versions? Since we aren't doing anything fancy, I don't want to require that they all use Java 12 or 13.  Any version 8 or above is fine. </p>
  
  <p>I also hesitate to tell the students to edit the properties above to match their machines because I assume that will cause problems if I pull their code and try to run it on my machine.</p>
  
  <p>Is there a way to configure Maven and the IDE to simply be happy with any JDK version 8 and above?</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;gvsucis&lt;/groupId&gt;
    &lt;artifactId&gt;ArrayLab&lt;/artifactId&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;ArrayLab&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.22.2&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.22.2&lt;/version&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
        &lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt;
        &lt;version&gt;5.6.2&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
        &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
        &lt;version&gt;5.6.2&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>