0

I've been developing in Java on OSX without issue for a couple of issues. Yesterday, I started getting weird compiler crashes (NPEs deep in javac).

I installed JDK 1.8.0_101, but javac is reporting itself as 1.8.0_20.

$ which javac
/usr/bin/javac

$ ls -l /usr/bin/javac
lrwxr-xr-x  1 root  wheel  74 20 Sep 15:16 /usr/bin/javac -> /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/javac

$ /usr/libexec/java_home 1.8
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home

$ echo $JAVA_HOME
Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home

$ java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

So everything's looking all awesome, but then:

$ javac -version
javac 1.8.0_20

Does anyone have any suggestions on what might be causing it to pick up the wrong version? I've tried removing all the JVMs and reinstalling, and rebooting, and all that.

Edit

Even running javac from the target of the symlink reports the wrong version. I've also confirmed that the md5 sum of /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/javac matches that of a healthy install.

3
  • Don't you have javac in the hash command output?
    – techraf
    Sep 21, 2016 at 1:35
  • Not sure I understand your comment. hash says javac=/usr/bin/javac. But even running javac from the symlink target reports the wrong version.
    – Martin
    Sep 21, 2016 at 1:38
  • which does not take into account bash command hashing thus it is not a good way to test. Anyway in your case it seems you are running the same executable, so it's not the case.
    – techraf
    Sep 21, 2016 at 1:41

1 Answer 1

0

Go to cd /Library/Java/JavaVirtualMachines. List all files using ls.

There should be two folders jdk1.8.0_101.jdk and jdk1.8.0_20.jdk. Enter sudo rm -rf jdk1.8.0_20.jdk.

Now check java -version and javac -version ,should be the same.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .