You want to install the 'JDK' for the latest version of the Java language. As of 9 May 2015 the latest version of Java is called Java SE 8u45
. There are two steps:
Press the big square button with a stylized coffee cup and the words 'Java' and 'Download' on this page.
You're now on a page entitled 'Java SE Development Kit 8 Downloads'. Press the radio button marked 'Accept License Agreement' and click on the link associated with your operating system, and follow the instructions in the installer.
Now it's time to persuade R to talk to your new Java installation. You can do this by typing
install.packages('rJava')
in R. If you're incredibly lucky, you're done. Try typing
library(rJava)
and if that works without complaint, check the version of Java that R sees by typing
.jinit() .jnew("java/lang/System")$getProperty("java.specification.version")
It should say
[1] "1.8"
If it does not then you're probably on a Mac and should read about the 'Mac Kludgerama' below.
If it does then you're good. Skip down to the final section on installing rjca.
The following is a variant of Andrew Goldstone's cunning workaround. I shall assume you want to use RStudio, but if you'd prefer to use the GUI that comes with R, then just replace every mention of RStudio
with R
in the instructions.
There are three steps:
Install a hopelessly out of date Java from Apple.
You may already have been prompted to 'install a virtual machine' during the process above. If you did that already, great. If you didn't, here's the link: http://support.apple.com/kb/DL1572. Press the blue button there to download the installer, and run it.
Re-install the 'rJava' package from source.
At an R prompt, type
install.packages("rJava", type='source')
Make a Desktop link to launch RStudio.
Open a Terminal window (you'll find the Terminal in the Utilities folder inside your Applications folder) and paste the following two lines into it
touch ~/Desktop/LaunchRStudio.command open -e ~/Desktop/LaunchRStudio.command
The second line opens a TextEdit window. Into that window paste the the following alarming incantation
1 2 3 4 5 6 7 8 | #!/bin/bash JVER=`java -version 2>&1 | head -n 1 | cut -d'"' -f 2` DYLD_FALLBACK_LIBRARY_PATH=/Library/Java/JavaVirtualMachines/jdk${JVER}.jdk/Contents/Home/jre/lib/server/ export DYLD_FALLBACK_LIBRARY_PATH open -a RStudio # replace with R if you'd prefer osascript -e 'tell application "Terminal" to close (every window whose name contains "LaunchRStudio.command")' & exit |
Now save the file and close the TextEdit window.
If you're curious, the incantation opens up a Terminal window to run itself, figures out which version of Java 1.8 you installed, opens a better informed version of RStudio that will play nicely with Java, and then tidies itself away once that's launched.
At an R prompt type
install.packages('devtools') ## if you don't already have it devtools::install('conjugateprior/rjca')
and load the package
load(rjca)
and maybe have a look at the introductory vignette to see what you can do with it
vignette('introduction', package='rjca')
If you've been following the Kludgerama, then you'll want to do all things rjca-related at an R prompt inside an RStudio that was launched by double-clicking that new file you just made on the Desktop.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.