Did you just recently upgrade to OSX 10.10? Were you for some ungodly reason running Java? If so, unless you moved your JDK & JRE directories, they're all gone! No big deal! Who wanted Java anyway right? Well if you're running applications such as BurpSuite natively within OSX, you're going to need an older version of Java for all of the features to function.
Addressing this issue is rather simple, download the versions you need and manipulate your bash profile through a variable which is then placed in your path and switch versions through commenting of that initial path variable.
#export JAVA_HOME=(/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/)
#export JAVA_HOME=(/System/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/)
export JAVA_HOME=(/System/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/)
export PATH="/usr/local/bin:/usr/local/sbin:/opt/msf:/usr/local/heroku/bin:$JAVA_HOME/bin:$PATH"
Simple huh? No mucking around with symlinks or the miserable Java manager UI. Uncomment the version you want and boom, done.
For all the new folks, we'll go over the steps on how we exactly got to this point along with some history.
With a clean upgrade/install the process is insanely simple. Download the required JDK DMG(s) that you want.
- Oracle Download Page
- Legacy Apple Java Download
Note, Apple maintained its own installation of Java prior to 1.7 and no longer supports Java whatsoever. If your application requires a legacy version and you're running OSX, there aren't that many other options.
Prior to moving on, it's important to understand the difference between JRE & JDK packages. JRE is merely a Java VM which runs Java applications whereas the JDK includes development resources as well as the JRE itself.
Oracle currently installs the JRE package in the following directory
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
Since we want to run Java 1.6, 1.7, and 1.8, let's assume that we've already downloaded them and executed the necessary packages to install them.
We're going to find the older Java 1.6 installation within this directory.
/System/Library/Java/JavaVirtualMachines/
Navigating to the following directory should show you the 1.7 and 1.8 installations.
/Library/Java/JavaVirtualMachines/
In the initial example above you'll notice that all of the JDK's were in the same directory. That's simply because I just moved them post installation to reduce a bit of complexity.
Otherwise we're going to define a variable and export it all within our bash profile, let's call this 'JAVA_HOME', which will point to the specific Java version we want.
export JAVA_HOME=(/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/)
We can create multiple variables with different paths and simply comment out the ones we don't want. Now we'll just throw that variable into our path and bam, Java.
This isn't new information by any means, I spent a considerable amount of time attempting to move or reconfigure the Java 1.6 directory structure over to the /Library/Java/JavaVirtualMachines directory and decided to simply leverage the common approach to the situation only after a few hours.
With the 1.6 installation of Apple's Java '/usr/libexec/java_home' symlink points to '/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home'. Why do I bring this up? There is a difference between framework and virtual machine directories that Apple had created, the frameworks folder has symlinks from previous Java versions everywhere.
To modify or make changes here breaks a number of things. If you need Java 1.6 simply install the Apple package and leave it alone. At the time Java was built into the operating system as an OSX framework for developers to play with. The intricate linking was designed to accommodate design decisions from previous versions and was not meant to be used directly.
- Legacy Apple Java Development Page
While anyone could sit down and read why Apple deployed Java the way they did or the directory structure, I thought I'd save a few people a bit of frustration.
Also if you're intentionally running Java, even worse, legacy versions of Java, please do your due diligence in locking down your system as it will not only protect your box but also the environments that you connect to and individuals you communicate with.