Loading rJava on Mac OS High Sierra
Asked Answered
L

4

6

I am trying to install rJava package for running the XLConnect package. Here are my system details;

R studio:Version 1.0.153

Mac OS High Sierra Version 10.13.1 (17B1003)

R version: 3.4.2

jdk-9.0.1

however, i get the following error:

enter image description here

I have already followed the following threads on this topic but they don't work for me:

trouble installing and loading rJava on mac El Capitan

rJava does not run on macOS Sierra

rJava load error in RStudio/R after "upgrading" to OSX Yosemite

A push in the right direction will be greatly appreciated !!

Lp answered 5/12, 2017 at 16:22 Comment(1)
Hi, did you ever manage to solve this problem? Having major issues here.Eugenle
B
4

I used the procedure at the following website: https://github.com/MTFA/CohortEx/wiki/Run-rJava-with-RStudio-under-OSX-10.10,-10.11-(El-Capitan)-or-10.12-(Sierra)

The main steps are:

  1. Install Apple Java 6
  2. Install the newest Java from Oracle
  3. Fix JAVA_HOME to point to the new version. Terminal command: sudo R CMD javareconf
  4. Install rJava from source. Terminal command: unset JAVA_HOME; R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")'
Blooming answered 17/1, 2018 at 21:24 Comment(2)
Someone downvoted this answer but didn't explain why. If this answer doesn't work, a comment would be helpful.Blooming
It worked for me, after trying lots of other options that didn't, so many thanks!Publication
F
0

My environment is

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

macOS High Sierra 10.13.2

I encountered this problem today and spent whole day trying to fix it. Luckily I found the solution at last. It works for me.

sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

Note:

If the get ln: /usr/local/lib/libjvm.dylib: File exists in terminal. Then you should delete this file and run the command above again.

Flatulent answered 9/2, 2018 at 9:11 Comment(1)
This is a frequently asked question & a major pain. Every time I have to install rJava on a new MAC there is some problem or the other. Right now this is the 4th stackoverflow question I am reading and have unsuccessfully tried to make it work. Is there a good thread where we can see step by step rJava installation along with all exceptions?Minetta
D
0

This worked for me on an M1 Mac:

  • Download jdk-19_macos-x64_bin.tar.gz from Java
  • Unzip the file and move it to /Library/Java/JavaVirtualMachines/ (may need to sudo su first)
  • Set export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-19_macos-x64_bin/Contents/Home'
  • Run R CMD javareconf
Domitiladomonic answered 3/11, 2022 at 16:25 Comment(0)
S
-1

@Kayle Sawyer's answer works almost perfectly, but you might need to reinstall command line tools first. Easiest way is to run the following in Terminal:

xcode-select --install

If you get an error saying command line tools are already installed, you can reinstall the package with this:

cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg

You might need to update the second command based on your OS version.

Answers from https://github.com/frida/frida/issues/338

Stepparent answered 28/10, 2018 at 20:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.