0

I'm using mac machine for native-script development and while executing an program it thrown an java error that:

Javac version 1.6.0_65 is not supported. You have to install at least 1.8.0.

so I checked with available install version on developer machine & found two different version detail:

/usr/bin/java -version Showing 1.6.

while system preference -> java control panel -> update. showing V1.8

any suggestion why two version !! Am I missing something here?

Update1: Following help to understand how mac handling this: /usr/bin/java is machine default location, and /Library/Internet.. which is manage explicit.

sudo rm /usr/bin/java
sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin

In my case I update default one with downloaded from internet.

Reference link Link1, Link2

CoDe
  • 11,056
  • 14
  • 90
  • 197
  • Though, primary issue has fixed. But still why mac managing multiple java version, it's confusing, what is purpose ? – CoDe Aug 02 '17 at 11:19

1 Answers1

1

You should use /usr/libexec/java_home instead

> /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home

you can use it to set JAVA_HOME

export JAVA_HOME=$(/usr/libexec/java_home)

then, you can put this one inside ~/.profile so you have always JAVA_HOME set to most recent release.

Oo.oO
  • 12,464
  • 3
  • 23
  • 45
  • You may be right. So in my case since I moved _/Library/Internet/.._ to _/usr/bin/_ so simply java -version giving me latest one which is downloaded from internet. BUT _/usr/libexec/java_home_ still contain 1.7 has highest version. So whoever use Environment variable JAVA_HOME they all get V1.7 only. Any suggestion over here. – CoDe Aug 02 '17 at 11:55
  • 1
    From Oracle's page: "Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS." Whenever you touch these files they can be changed. I suggest to install JDK from Oracle and set JAVA_HOME to most recent version. – Oo.oO Aug 02 '17 at 12:00
  • How can be keep all version same, is this really required to keep multiple version ? – CoDe Aug 02 '17 at 12:00
  • 1
    If you don't need them, you can always remove versions you don't need: https://docs.oracle.com/javase/9/install/installation-jdk-and-jre-macos.htm I guess this is more question to Apple and Oracle. And, note one more thing! To make things even more messy, you can have Java from Apple (different layout) and from Oracle. Oracle's layout is way more similar to other systems. You can take a look here for some info regarding Java struggles in macOS: http://www.owsiak.org/?p=3671 – Oo.oO Aug 02 '17 at 12:10
  • Thanks, well upgrade to new version from 1.7 to 1.8 fixed the issue, but why 2-3 java version issue is still remain in mind. – CoDe Aug 03 '17 at 23:27