Search code examples
javarmacosterminalrjava

Issues with rJava and Terminal inputs for Mac


I am trying to update RJava to reflect the latest version of Java 1.8 on my mac. I think I found the right information in doing so but the issue arises when I use 'Terminal' to run some code. I have to run:

sudo R CMD javareconf -n

but I receive an error of:

sudo: R: command not found

I found some information online and I found out I need to change the path in Terminal. I found out that the path where R is '/usr/bin/R'. When I changed the path using the command:

export PATH=/usr/bin/R:$PATH

and then tried to run the code again; I got no where and I am out of luck. I don't understand what the code is but I can only assuming what it does. Hopefully I can get some insight on how I can change the path so I can update rJava to the updated Java Version. Thank you for anyone's time.


Solution

  • The PATH setting would be PATH=/usr/bin:$PATH or you even easier

     sudo /usr/bin/R CMD javareconf
    

    Note that -n wouldn't do anything so you probably didn't mean that. Also if you don't even have /usr/bin on your PATH, you have probably even bigger issues since you also need to find java in the first place. In cases like that you may have better luck using sudo -i and then using the shell to fix whatever env vars are not setup correctly in your system.