How does /usr/bin/java work on Mac

java

I found /usr/bin/java linked to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java. And its file content is different from /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java. But when I type /usr/bin/java -version it prints

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

So I'm curious about the implementation of /usr/bin/java and wondering why it can always point to the latest version of my JavaVirtualMachines?

Best Answer