Using OS X Mavericks, and after upgrading my JDK, I can no longer compile with ant.
I've done the usual googling and the vast majority of answers point to JAVA_HOME not being set.
Help me stackoverflow, you're my only hope!
Information which may be useful
$ tail -n1 /etc/profile
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
$ which javac
/usr/bin/javac
$ ls -lah /usr/bin/javac
lrwxr-xr-x 1 root wheel 75B 8 Jan 11:23 /usr/bin/javac -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac
$ ls -lah /System/Library/Frameworks/JavaVM.framework/Versions/
total 80
drwxr-xr-x 13 root wheel 442B 19 Mar 10:10 .
drwxr-xr-x 12 root wheel 408B 19 Mar 09:59 ..
lrwxr-xr-x 1 root wheel 10B 8 Jan 11:23 1.4 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10B 8 Jan 11:23 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10B 8 Jan 11:23 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10B 8 Jan 11:23 1.5.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10B 8 Jan 11:23 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10B 8 Jan 11:23 1.6.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10B 19 Mar 10:10 1.7 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10B 19 Mar 10:10 1.7.0 -> CurrentJDK
drwxr-xr-x 8 root wheel 272B 8 Jan 11:23 A
lrwxr-xr-x 1 root wheel 1B 8 Jan 11:23 Current -> A
lrwxr-xr-x 1 root wheel 58B 19 Mar 10:10 CurrentJDK -> /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents
$ javac -version -source 1.7 -target 1.7 -fork true
javac 1.7.0_51
javac: invalid source release: 1.7
Usage: javac <options> <source files>
Thanks to @david-w for the effort and helping narrow down the problem.
To solve, I had to
sudo cp $JAVA_HOME/lib/tools.jar /Library/Java/Extensions/
as mentioned here
silly os x
The solution in the accepted answer didn't work for me; I got the error:
tools.jar: No such file or directory.
However, I found a working solution here. In short, I installed the latest version of the jdk from Oracle website and this solves the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With