[R] Problem when trying to run Java in R:
David Winsemius
dwinsemius at comcast.net
Mon Oct 23 04:17:03 CEST 2017
> On Oct 21, 2017, at 4:35 AM, Morkus via R-help <r-help at r-project.org> wrote:
>
> Hello All,
>
> Although running Java from R used to work, for some mysterious reason, it's stopped.
>
> Today when I tried to load a basic JDBC driver (or the sample .jinit()) code, I got:
>
> - JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
>
> - JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
>
> - JavaVM FATAL: Failed to load the jvm library.
>
> I saw postings on StackOverflow about this issue, but none of the suggested fixes helped.
>
> I'm on Mac OS 10.13.
>
> My JAVA_HOME is: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
>
> java -version
> java version "1.8.0_144"
I am not sure why but I do notice that currently: Java Recommended Version 8 Update 151
AND this quoted warning is on the current download page ..
macOS Sierra 10.12 users: A few issues have been reported on Sierra. See FAQ for more information.
Others have reported success with this at the Terminal command line:
sudo R CMD javareconf
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home"
export LD_LIBRARY_PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/server
#AND then .... at the R command line:
install.packages('rJava', type='source')
> Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
> Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
>
> I'm using R: 3.3.3
>
> Here is sample code that also throws this same error:
>
> library(rJava)
> .jinit() # this starts the JVM
> s <- .jnew("java/lang/String", "Hello World!")
I don't get any error running:
sessionInfo()
R version 3.4.2 Patched (2017-10-04 r73465)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] grDevices utils datasets graphics stats methods base
other attached packages:
[1] rJava_0.9-8 dplyr_0.7.2 gmodels_2.16.2 Matrix_1.2-11 xgboost_0.6-4
[6] rms_5.1-1 SparseM_1.77 Hmisc_4.0-3 ggplot2_2.2.1 Formula_1.2-1
[11] survival_2.41-3 sos_2.0-0 brew_1.0-6 lattice_0.20-35
loaded via a namespace (and not attached):
[1] Rcpp_0.12.11 mvtnorm_1.0-6 gtools_3.5.0 visNetwork_1.0.3
[5] zoo_1.8-0 assertthat_0.2.0 digest_0.6.12 R6_2.2.2
[9] plyr_1.8.4 backports_1.1.0 acepack_1.4.1 MatrixModels_0.4-1
[13] rlang_0.1.2 lazyeval_0.2.0 mxnet_0.10.1 multcomp_1.4-6
[17] gdata_2.17.0 rstudioapi_0.6 data.table_1.10.4 rpart_4.1-11
[21] gamlss.data_5.0-0 checkmate_1.8.3 DiagrammeR_0.9.0 splines_3.4.2
[25] stringr_1.2.0 foreign_0.8-69 htmlwidgets_0.8 igraph_1.0.1
[29] munsell_0.4.3 compiler_3.4.2 influenceR_0.1.0 rgexf_0.15.3
[33] pkgconfig_2.0.1 gamlss_5.0-2 base64enc_0.1-3 gamlss.dist_5.0-0
[37] htmltools_0.3.6 nnet_7.3-12 tibble_1.3.1 gridExtra_2.2.1
[41] htmlTable_1.9 codetools_0.2-15 XML_3.98-1.7 viridisLite_0.2.0
[45] MASS_7.3-47 grid_3.4.2 nlme_3.1-131 polspline_1.1.12
[49] jsonlite_1.5 gtable_0.2.0 magrittr_1.5 scales_0.4.1
[53] stringi_1.1.5 viridis_0.4.0 bindrcpp_0.2 latticeExtra_0.6-28
[57] sandwich_2.3-4 TH.data_1.0-8 RColorBrewer_1.1-2 tools_3.4.2
[61] glue_1.1.1 Rook_1.1-1 parallel_3.4.2 colorspace_1.3-2
[65] cluster_2.0.6 knitr_1.15.1 bindr_0.1 quantreg_5.33
Running this produces:
Sys.getenv()[grep("jre", Sys.getenv())]
#DYLD_LIBRARY_PATH /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server
--
David.
>
> (this is the "hello world" equivalent from the rJava site)
>
> ----
>
> I also tried to use Java 7 (rev. 51), which used to work, but that still fails.
>
> Also tried a fresh install of R/RStudio on another machine with the same results (same Java version, etc., however).
>
> I suspect Java itself is working fine since JDBC code from Java programs has no issues.
>
> Not sure why loading Java in R stopped working, but would appreciate any suggestions.
>
> Thanks very much,
>
> Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius
Alameda, CA, USA
'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law
More information about the R-help
mailing list