Javac 8 on Mac OS won't compile and won't talk about it 1.7

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'm pretty sure I am running the compiler from Java 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 javac says 1.7

  > javac -version
  javac 1.7.0_60

      

Maybe Apple (Oracle?) Bundled the wrong compiler version with the JDK? Or is there something else I am doing wrong?

EDIT: The result is the same regardless of whether my $ PATH contains any java directories or not (usually it doesn't):

> which java
/usr/bin/java
> which javac
/usr/bin/javac

      

EDIT 2: One weird thing I found is the reported version of the javac compiler, no matter 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 javacs be symbolic links to one? No, it turned out that there are no symbolic links:

>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

      

+3


source to share


3 answers


The decision was in response to this: fooobar.com/questions/148040 / ... . It turns out javac executes ~ / Library / Java / Extensions / tools.jar if it finds one. So remove ~ / Library / Java / Extensions and you should be fine.



Thanks to https://stackoverflow.com/users/3439760/user3439760 for discovering the answer and Franco Azabache for finding the link for me.

+1


source


You probably have a directory jre/bin

in the path before jdk/bin

. The command javac

does not exist in the installation jre

.



0


source


I had tools.jar

in: /Library/Java/Extensions

after deleting it, javac -version

pointed to JAVA_HOME

at this point.

0


source







All Articles