Intellij - Error:java: invalid source release: 1.8
<p>While trying to run tests, I ran into this compilation error:</p>
<p><img src="https://i.stack.imgur.com/S4epb.png" alt="invalid source release: 1.8" /></p>
<p>I tried researching this on Google and here, and after applying all of the solutions that worked for others this issue still persists.
Here is what I have done so far:</p>
<ul>
<li>Preferences -&gt; Java Compiler: set 'project bytecode version' to 1.8
<ul>
<li>I also set the target bytecode version to 1.8 for each individual module as well</li>
</ul>
</li>
<li>Preferences -&gt; Build, Execution, Deployment -&gt; Build Tools -&gt; Maven -&gt; Runner: Set JRE to use Project JDK (which correctly displays as 1.8)</li>
<li>Project Structure -&gt; Project: set Project SDK to 1.8 and language level to 8</li>
<li>Project Structure -&gt; Modules -&gt; Sources: set language level to 8 for each module</li>
<li>Project Structure -&gt; Modules -&gt; Dependencies: set Module SDK to 1.8</li>
</ul>
<p>I think this issue may have something to do with a discrepancy between the JDK and the compiler.
When I run <code>java -version</code> from the terminal it returns 1.8.0_111. However when I run <code>javac -version</code> it returns 1.7.0_79. I looked for ways to force change the javac version to match the java version but nearly all of them reference <code>update-alternatives</code> which is not available for Mac OS or removing /usr/bin which is not allowed (even with sudo) on El Capitan.</p>
<p><strong>Workaround Edit:</strong><br />
I was able to bypass the issue by going to Preferences -&gt; Build, Execution, Deployment -&gt; Compiler -&gt; Java Compiler and changing the compiler from &quot;javac&quot; to &quot;Eclipse&quot; and I am able to compile my project.</p>