Getting R and Java 1.8 to work together on OSX

December 29, 2014

(This article was first published on Will Lowe » R, and kindly contributed to R-bloggers)

Hey Mac OSX users with Java 1.8 installed. Did R just request a Java 1.6 installation and then promptly crash your session?  If so, read on…

The Problem

A few days ago I was attempting to use the mallet package for topic models and I found that typing

> library(mallet)

caused two things to happen:

  1. The operating system launches a dialog asking whether I would like to download Java 1.6
  2. The R session crashes (regardless of what I did about the dialog)

This seems to be a general problem for packages that depends on the rJava package.

I’m running the latest Mac OSX (Yosemite 10.10.1) and have installed the latest Java

$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

and the latest R

$ R --version
R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

But for some reason with R, it’s Java 1.6 (which is no longer even being updated) or bust.

The fix (maybe)

The trail of bug reports starts here, but before you delve into those and bother Simon Urbanek as much as I did, try the following:

  1. Download and install Apple’s Java version 1.6 like you were asked to.
  2. Reconfigure your R installation by typing
    sudo R CMD javareconf -n

    in a Terminal window

  3. Trigger a recompile by reinstalling rJava by typing
    install.packages('rJava', type='source')

Now if you relauch R and load your package it should use your shiny new Java 1.8 and not crash any R sessions.


To leave a comment for the author, please follow the link and comment on their blog: Will Lowe » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)