IntelliJ, Play! and class file version

IntelliJ version: 12.1.4

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.8.5
BuildVersion:   12F45

I work on a Play! framework Java project and the project is set to use JDK 1.7.0_45 but when I want to run unit test I face the following problem:

/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java [...]
Exception in thread "main" java.lang.UnsupportedClassVersionError: service/CfpUserServiceTest : Unsupported major.minor version 52.0
 at java.lang.ClassLoader.defineClass1(Native Method)

And it makes sense because running javap on on of the test class file shows:
Classfile /Users/blep/dev/Breizhcamp-cfp/target/scala-2.10/test-classes/service/CfpUserServiceTest.class
  Last modified 25 janv. 2014; size 1683 bytes
  MD5 checksum 25f99a4fa37e2b2a2224c482d1131f4c
  Compiled from "CfpUserServiceTest.java"
public class service.CfpUserServiceTest
  SourceFile: "CfpUserServiceTest.java"
  InnerClasses:
       #12; //class service/CfpUserServiceTest$2
       #9; //class service/CfpUserServiceTest$1
  RuntimeVisibleAnnotations:
    0: #72()
    1: #73()
  minor version: 0
  major version: 52
  flags: ACC_PUBLIC, ACC_SUPER

So it means the file is compiled with an existing JDK8 on my machine but this JDK installation is not set in the project.

If I use '$ open -a "IntelliJ IDEA 12"' terminal command to open IntelliJ in a shell where JAVA_HOME env var is set with the 1.7 jdk home directory, the files are compiled with the expected JDK and the tests run fine inside the IDE.

Does somebody knows why IntelliJ uses JDK 1.8 when IntelliJ is openned with the Finder?
 

Please sign in to leave a comment.