-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rJava fails to load #2254
Comments
I think this is because the rstudio/src/cpp/desktop-mac/AppDelegate.mm Lines 216 to 224 in aa92289
But in 1.2 we just look in supporting files: rstudio/src/cpp/desktop/DesktopPosixDetectRHome.cpp Lines 53 to 57 in ad3e90d
|
Note that this problem occurs in R, not just RStudio. The problem still occurs in Mac Desktop 1.2.405. I tried with both Java 1.8.0_161 and 9.0.4. In both cases, they failed with messages similar to, but not exactly, as above (probably because we have R installed in different places:
On the instance with Java 9.0.4:
|
@ronblum: does running
help in this case? (That typically needs to be run after an update of the system Java installation) |
Yes—thank you! |
I don't think this rJava problem on MAC OS is anywhere but solved. I have 3 macs all updated to OS HighSierra (10.13.5). On every Mac this problem is there and when I move from one mac to another I usually have to repeat all the steps but this time it is being very sticky. There is a huge chunk of error messages and I am not sure which of the steps are the valid sequence. I tried downloading, restarting R session, reconfiguring by
But no success. When I run
When I restart R session:
I also checked there is nothing in the subdirectory:
|
All, I was able to repair the issue. I have High Sierra 10.13.5, and after updating to the latest Java update and running the "sudo R CMD javareconf" at the terminal prompt it corrected the issue in RStudio. |
@sanjmeh: have you installed a Java Development Kit? You need one if you want to use |
I also have a similar issue when installing the "rJava" library it gives me the error
any help would be appreciated |
why was issue closed ? |
Because, to the best of our knowledge, the RStudio-side issues are fixed. If you're still having trouble, please open a new issue or consider posting at https://community.rstudio.com. |
why was issue closed ? |
Downloading GitHub repo CommerceDataService/eu.us.opendata@master
|
The error suggests that Please consider posting on https://community.rstudio.com if you need more help. You also likely need to run
to reconfigure |
I had the same issue with rJava and xlsx in both base R and Rstudio. It started to happen after I updated to Mac High Sierra 10.13.3. Not sure how it was ultimately solved but I followed the following steps more or less in this order: Installed Java version suggested in: Then, tried adding the line: At this point things still did not work. Tried one suggestion in following page: Still no better. Lastly, I followed "kevinushey" suggestion above: Installed Java Dev Kit. Then, ran "sudo R CMD javareconf" on command line. Re-started R base and Rstudio and the problem was fixed. Thanks to all. |
@jerrybreak Thanks, the following really works
|
I had rJava working last month but now again the same error (Upgraded to High Sierra and played with .profile a bit during the month setting up NVIDIA - if that helps). But this is a never-ending pain (rJava sucks). After I ran
|
I too had lots of probs and tried all of the above to no avail. What worked for me (your milage will vary!) was doing this inside RStudio:
|
Note that using Java 9 with R is not recommended -- you should prefer either Java 8 or the current version of Java (which appears to be Java 11.0.1). But Java 8 is more widely supported + tested. |
I was experiencing the same issue loading rJava into Rstudio and tried all of the solutions suggested above with to no avail. The solution that worked for me was the top answer suggested in this SO post. However, the key was the suggestion by Dave X to both link the After having linked |
I had this problem too (OS X 10.12.6, R 3.5.0, RStudio 1.1.453, Java 1.8.0_144). I already had Java installed, I installed Then, I tried:
Not sure why, but it seems like a restart of RStudio was needed for me to get everything synced up. |
Same here.
|
That's really work well to me. |
For me as well. I did the following steps:
|
I had the same issue with the note:
My mac is running with 10.14.6 Mojave, and I have both JDK 10.0.1 and JDK 11.0.4 installed.
Or if you have multiple versions of JDK, just follow my example:
Save it and run
|
Hi @Kinroadzxc, I run into this problem as well and after all, I agree that the problem might be caused by the After installing Java JDK 11.0.1, it works man :)))))))))) |
@kevinushey This should be reopened since the most discussion is here, and there is a new twist in Catalina. rJava will work fine in the terminal, but RStudio won't load rJava unless I specify a dyn.load of the jdk like: The problem is that it isn't persistent, and no matter what I tried with the paths, or different jdk versions, it still errors every time I start RStudio fresh unless I do that. [Catalina is a mess and I'm rolling back. Lots of things not working. My cron jobs don't fire for R etc...sigh.] |
I'm not able to reproduce -- R (and RStudio) are both able to successfully load
to make sure R was aware of my Java installation, though. I also have |
I spent about six hours on it today. I upgraded to 15.0 Catalina from Mojava 10.14.6. Immediately I had segfaults on my package heavy and RAM intensive scripts. I have around 20 dependencies. I updated to the latest RStudio from 1.1.463, but that just somehow installed 3.6 over my 3.5.2. My scripts only work with 3.5.2, so I played around and then set my path back to 3.5.2. It was still the same problem. I never figured out how to make rJava work without manual intervention, and the segfaults persisted even when I reinstalled Catalina and did this whole thing from scratch. It's really annoying, but I wouldn't tear your head out trying to reproduce. There are a lot of variables. Just keep it in mind, because nobody who uses R should update to Catalina unless they like pain. I hope future versions can improve the process. I found that the tool to switch R versions was 32 bit, so that made things even more fun. :-) Edit: Forgot to say that I got segfaults exactly the same in RStudio and in the terminal, so it's probably not RStudio causing those. |
@woodydeck An aside: there's a new 64-bit RSwitch app at https://github.com/hrbrmstr/RSwitch/tree/master/releases . We're not "officially" stating support, but I've been using it with success. And in general, the author is very involved with R and RStudio. |
I was experiencing this issue on macOS 10.15, R 3.6.1, rJava 0.9-11, RStudio 1.2.5019. After many hours of languish, I finally discovered a working solution here: rJava #151. I ran the below from the terminal:
I was then able to load rJava successfully in RStudio. |
I experienced the same issue as @stuartsoorholtz on macOS 10.14.6, R 3.6.1, rJava 0.9-11, RStudio 1.2.5019. Like @stuartsoorholtz, I resolved the issue by modifying Initially, in R started from the terminal
The error message tells us, that it tries to load the library from a folder
Now, we can modify this path in
After that, RStudio could load the |
For me on Ubuntu Server 18.04, What worked was adding |
I had the same issue on mac OS 10.14.6, R3.5.1. I followed the same steps as @fabern (followed instructions from here: http://www.owsiak.org/r-java-rjava-and-macos-adventures/) but then had an additional error with -fopenmp
I had to change gcc to version gcc@7 which I did by following the comment here, beginning at "Error (unsupported option '-fopenmp)": |
Here I am again updating from macOS Sierra (see above comment) to now Catalina 10.15.2. At the same time I also updated to Rstudio 1.3.776. Then, rJava failed to load in base R and Rstudio but not in the terminal. The following was the error from base R and Rstudio:
So, I don't remember the exact order of events but after a couple of days of going nuts trying to fix this I ended up fixing it (I think). From the start I ran the almighty "sudo R CMD javareconf" and it was complaining about an error. Sorry I no longer have the error in my terminal. Then, I went ahead and downloaded java JDK version 11.0.1 (I had 11.0.6) because that was exactly the version under JavaVirtualMachines/ the error message was specifying above. I downloaded it from here Nothing was working yet but I realized that the Then again the
At some point in the series of events above, I also realized (because some other thread and some other error) that I did not have the most up to date version of Xcode, so I went to the app store and updated it to the suggested version. I think I was getting the following error when trying to use something similar to what @stuartsoorholtz said above:
But modified to the jdk versions I had. So, after updating Xcode, I continued to get the same error so I think that didn't really work for me. So, by now rJava was loading ok now but xlsx was not. I was about to give up using xlsx but then I decided to install the most recent version of JDK 13.0.2 from, then re-ran the java reconf command on the terminal and it worked!! I was able to load xlsx. So, in summary, I think I needed the JDK 11.0.1 version first to be able to make the java--R connection work (somewhere in some thread I read apple no longer supports some sort of automatic link that communicates with Java). Then, once I was able to load rJava but not xlsx, I think I needed JDK 13.0.2 and reconfigure java to make xlsx work. Why? I wouldn't know. One odd thing that happened the very first time I actually used the
So, I don't know if the warning was kicked in by java or by R. But then, the xlsx file loaded fine and subsequent use of xlsx in new R sessions have not spit out the same warnings. By the nature of the warning I think I may have done something "illegal" but I guess I don't know enough about this stuff. Anyway rJava and xlsx work for me now. By the way, at some point during my suffering I also uninstalled and reinstalled rJava so I don't know if that also helped or not. I was using Good luck. I don't think I'll ever upgrade to a new macOS version again. |
You can also just copy the jdk folder to the one Rstudio wants to see. That worked for me. |
@saudiwin do you mean copy the jdk directory into |
No just copy the jdk library that's actually installed in This strategy is a hack and I'm sure it could break down at points as the versions of Java aren't actually the same. But given that there's no direct solution proposed yet, I thought I would post. |
You made my day!!!!!!! |
FWIW I tried R CMD javareconf but it only worked using R in a terminal but not in Rstudio for some reason. I'd get the error
@fabern's solution worked for me, however i had to find I identified the location of
And now rJava works on both terminal and RStudio. |
I had this problem on macOS 10.14.6 with R version 3.6.1 and RStudio version 1.2.1578. I tried just about everything in this thread, but eventually solved it simply by installing jdk 11.0.1, which seems like what rJava requires, and then running |
I'm having problems installing rJava
I don't know what to do. I'm on MacOsMojave. The broader context of what I'm trying to do is to get the Stanford NLP library to work install.packages("coreNLP") |
This solution from @hmorzaria worked for me (thank you!). However, I'll just add that in the case of RStudio Server, restarting the R session alone did not work, I had to restart RStudio Server itself via the command
|
Finally it worked for me:
Then it prompted me to put my computer password. Then it configured it successfully.
Best wishes. Evans |
You can check this link too may be useful ( https://kodlogs.net/306/rjava-could-not-be-loaded) |
I have the exact same problem loading rJava: Error: package or namespace load failed for ‘rJava’: This is after installing Java, installing JDK, running sudo R CMD javareconf in the terminal, and starting up RStudio and trying to load the rJava library. In short, this problem still exists in 2023 even after all this big long discussion and all these detailed pointers! UPDATE: I just solved my problem! I installed the wrong JDK. The first time, I installed ARM64 Compressed Archive. I needed to install ARM64 DMG Installer for some reason. At least, when I tried installing that one, and typing sudo R CMD javareconf in the terminal, the output from running that command was completely different than the questionable output I kept getting before, and when I opened RStudio afterwards, rJava simply loaded, no problem. |
@jcutlerbiostats I'm glad to hear that this resolved the issue! |
System details
Steps to reproduce the problem
library(rJava)
Describe the problem in detail
Describe the behavior you expected
We should be able to load
rJava
.Notes
It looks like, in v1.2, we're setting the wrong environment variable:
The text was updated successfully, but these errors were encountered: