I have installed JDK 1.8.0_25 on Mac OS X. It complains when trying to compile Java 8 sources:
> javac -source 1.8 ComposableList.java
javac: invalid source release: 1.8
I am sure I am running the compiler from the Java 8 JDK:
> which javac
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/javac
> java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
However the javac says it's 1.7
> javac -version
javac 1.7.0_60
Could it be that Apple(Oracle?) bundled wrong version of the compiler with the JDK? Or is there something else I am doing wrong?
EDIT: The outcome is the same regardless of whether my $PATH contains any java directories or not (normally it doesn't):
> which java
/usr/bin/java
> which javac
/usr/bin/javac
EDIT 2: One strange thing I found was the reported version of the javac compiler is the same regardless of which compiler I run:
> /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin/javac -version
javac 1.7.0_60
> /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/javac -version
javac 1.7.0_60
> /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/javac -version
javac 1.7.0_60
EDIT 3: as @dan suggested, could all javac being symlinks to a single one? Nope, it turned out there are not symlinks:
>ls -l /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/javac
-rwxrwxr-x 1 root wheel 99376 Sep 17 17:13 /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/javac
> ls -l /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/javac
-rwxrwxr-x 1 root wheel 99360 Mar 18 2014 /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/javac
The solution was in this answer: https://stackoverflow.com/a/22547808/130228 . Turns out, javac executes ~/Library/Java/Extensions/tools.jar if it finds one. So delete ~/Library/Java/Extensions and you'll be fine.
Thanks to https://stackoverflow.com/users/3439760/user3439760 for discovering the answer and to Franco Azabache for finding the link for me.