For most, this would come in handy with those using the latest browser extensions/add-ons that use Java, especially version 7 (in the time of this writing). There are two ways to go about this. First, for most users, they just need the JRE. The second are those doing development work and need the JDK.
Before we start the installation process, let’s start with some preflight check and do the following in Terminal prompt:
$ java -version
This will give you 1.6.x of some degree. Now, let’s start the installation.
If you just need the JRE:
- Download the JRE here.
- Follow the instructions, and install onto your OS X system.
- In your ~/.profile, ((Or .bashrc, .bash_profile, etc.)) add the following:
export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
- Open a new Terminal window, and run the following to check you are running the intended version:
$ java -version
This should give you something like the following results:
$ java -version
java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
For those that need the JDK, and running Homebrew, you may do the following:
- Download the JDK here.
- Install jenv via Homebrew: ((Be sure to brew udpate and run brew doctor before adding any new packages, always.))
$ brew tap jenv/jenv $ bre install jenv
More info here.
- Add the following in your Bash files by running these in Terminal: ((Again, these can be .bashrc, .bash_profile, etc.))
$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.profile $ echo 'eval "$(jenv init -)"' >> ~/.profile
- Configure jenv by running the following for example:
$ jenv add /Library/Java/JavaVirtualMachines/jdk17011.jdk/Contents/Home
oracle64-1.7.0.11 added - Last but not least, check that you are running the intended version in Terminal:
$ java -version
I hope that helps.