- #SWITCH JDK ON MAC BUT HOW TO#
- #SWITCH JDK ON MAC BUT MAC OSX#
- #SWITCH JDK ON MAC BUT UPDATE#
- #SWITCH JDK ON MAC BUT WINDOWS#
![switch jdk on mac but switch jdk on mac but](https://i.ytimg.com/vi/043tTKcmk2c/maxresdefault.jpg)
Here is the approach I now take for switching Java versions, but still allowing other programs to pick there favorite JDK: eclipse, ant, maven, your own java programs, etc.
![switch jdk on mac but switch jdk on mac but](https://netbeans.apache.org/download/nb110/nb11-new-project.png)
![switch jdk on mac but switch jdk on mac but](https://netbeans.apache.org/download/nb110/jep-325-hint-1.jpg)
There is a new program to help us (/usr/libexec/java_home) and you should read up on it by doing a “man java_home”.Apple needs to maintain backwards compatibility, which means the mess will be with us for awhile.There is a mess with how Java versions are installed and Apple’s approach to this is changing.The most informative find I came across that helped me understand the issue better was a thread on and can be summarized as follows. They are not immune to having outdated documentation and I have found lots of examples that point to information that is roughly 2 years out of date. Just google any of the following phrases and you’ll see what I mean:Įven Apples’ own java development support site has it wrong now, according to my latest findings. There are several articles on switching Java versions on the Mac and where you should point JAVA_HOME. The problem is finding their recommendations. After my research, I am a now a strong proponent of using the recommendations of Apple and tools that are provided. If you have JAVA_HOME set somewhere else, then all bets are off.īTW, there is a lot of debate as to whether you should or should not manipulate these links manually. These versions are supposed to pick the top version of Java from your Java Preferences app settings. This directory holds (among other things) a bunch of shared command line tools under the Commands subdirectory (like java, javac, etc.) that are available to user programs. Under that is a directory called Versions and under that is a slew of versions, links, and a suspicious directory called A. If you have tried to find where Apple stores all these versions, you may have discovered the /System/Library/Frameworks/JavaVM.Framework directory. Apple uses several soft links to provide a “flexible” way to refer to a particular Java version and they recently changed how this works.Just setting JAVA_HOME in your shell can cause unexpected behavior if you don’t know how Apple installs Java on the Mac.Using a ‘plist’ (preferences list) file, specifically ~/.MacOSX/ist.Within your shell using normal environment variables, exactly as you would expect from Linux.The Mac has a couple different ways to set environment variables that are accessible to Java programs.
#SWITCH JDK ON MAC BUT HOW TO#
This article shows you how to use the Java Preferences App, but the methods presented for switching Java versions is out of date. The Mac includes a Java Preferences App (Applications -> Utilities -> Java Preferences) that lets you set the preferred order of Java versions to run when you launch a Java application or applet within a browser.With UPD4 (and some earlier updates), Java 6 is installed as well, but it is not set as the default JDK.
#SWITCH JDK ON MAC BUT MAC OSX#
Mac OSX 10.5 comes with Java installed by default and includes multiple versions. Even though you might get away with this for a little while, it will bite you eventually for various reasons. Here are a few concepts that need to be understood about the Mac/Java environment before you go off and just try to set JAVA_HOME in your favorite shell environment to some other location. If you just want to fix it quick, because something broke since you installed UPD4, then see the Bottom Line below.įor those that want to know a little bit more why your environment broke and the Java Preferences app doesn’t seem to do what you think it should, please read on.
#SWITCH JDK ON MAC BUT UPDATE#
These articles were valid until some very recent updates to Java were released, specifically the Leopard 10.5.7 Java Update 4 (referred to as UPD4 from here on). This article is also intended to correct many other (now incorrect) articles attempting to help with the same issue.
![switch jdk on mac but switch jdk on mac but](https://miro.medium.com/max/1400/1*VndUoCGNKl5Bg1iC28Ay8A.png)
#SWITCH JDK ON MAC BUT WINDOWS#
This blog will point out a few things you might not expect coming from a Windows or Linux environment. Switching Java versions from say, Java 5 to Java 6 or back is (probably) not intuitive for the new Mac user.