Ask Different Asked by Maverik on February 5, 2021
I have two versions of Java installed with Mountain Lion:
The update from Apple removes Java Preferences. In another question someone wonders about the removal of that utility.
My question is different:
I previously used Apple’s utility to set Java preferences with ease. Without that utility, is there an easy and fast way?
based on user2343996's answer
alias java8="export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) && java -version"
alias java6="export JAVA_HOME=$(/usr/libexec/java_home -v 1.6) && java -version"
Answered by existeundelta on February 5, 2021
Open up a terminal use this command:
/usr/libexec/java_home -v 1.6
You can change the 1.6 to any version of java you want to use and the command will output the location of where that version of java resides. (i.e: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home)
then you can set the JAVA_HOME like you normally would with the output of the previous command. i.e.:
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
So to simplify; something like this should work:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)
remember to check the version with:
java -version
Hope it helps.
Answered by user2343996 on February 5, 2021
You may need two approaches:
My recent use case:
sudo mv /Library/Internet Plug-Ins/JavaAppletPlugin.plugin /private/var/tmp
If you plan to switch frequently, you may prefer a different temporary location.
sh-3.2$ java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b58)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b02, mixed mode)
sh-3.2$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.8.2
BuildVersion: 12C60
At the same time:
Answers under:
Install JDK 7 Update 09 then JDK 8
Quit any apps that use Java. No need to quit the browser.
Set aside the jdk1.8
… directory from
/Library/Java/JavaVirtualMachines
Quit any apps that use Java. No need to quit the browser.
Set aside the jdk1.7
… directory from
/Library/Java/JavaVirtualMachines
macbookpro08-centrim:~ gjp22$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
macbookpro08-centrim:~ gjp22$ sudo mv /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk /private/var/tmp
Password:
macbookpro08-centrim:~ gjp22$ java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
For users of OS X, some of what's provided by Oracle is initially misleading:
… and so on.
Whilst none of the above is as simple as switching with the Java Preferences app previously installed by Apple, the relatively simple approach of setting aside (no need for special uninstallation) is reminiscent of the wish for drag-and-drop installation … previously expressed in the openjdk-osx-build area.
Someone might like to build an app, but I should not recommend using symlinks – it would work, but could be inconsistent with future drag-and-drop approaches to installation.
At the time of writing, the most recent supported releases for which Oracle makes updates publicly available are (for platforms other than OS X) Java 6 Update 37 and (for platforms including OS X) Java 7 Update 9.
As greater releases will be made available, please reinterpret this answer accordingly.
Java version terminology in this answer is in line with Java Help Center terminology.
Answered by Graham Perrin on February 5, 2021
It looks like you'll have to do it manually. Oracle's documentation states that only one JRE can be installed at a time.
This Apple support page describes how to switch between the Apple SE 6 JRE and the Oracle SE 7 JRE. Briefly, to switch from Oracle's JRE back to Apple's, start the Terminal app and type the following:
sudo mkdir -p /Library/Internet Plug-Ins/disabled
sudo mv /Library/Internet Plug-Ins/JavaAppletPlugin.plugin /Library/Internet Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
There are more (and better) instructions on the support page on how to switch Web Start back to JRE 6, and how to switch everything back to Oracle JRE 7 (reinstall the JRE).
Not as simple as using the Java Preferences utility, but better than nothing.
Answered by dfjacobs on February 5, 2021
Why do you need to have 2 versions of Java installed?
Apple doesnt have Java installed as a default update (from Lion onwards I believe). The best way to check for/install Java on a Mac is as follows :
If you want to install a different version of java : Just goto the oracle site and download the newest/older jdk.
Answered by SashaZd on February 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP