Unable to install R JavaGD package on OSX - java

I have tried to install the R package JavaGDon MacOS 10.14.6. My R version is 3.6.1. When I do instal.packages there is apparently no error, but when I do in R console:
library(JavaGD)
Error: package or namespace load failed for ‘JavaGD’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/JavaGD/libs/JavaGD.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/JavaGD/libs/JavaGD.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/JavaGD/libs/JavaGD.so
Reason: image not found

It should work fine in macOS 10.14.
However, make sure your R and Java environments are correctly configured.
It might be a little bit of struggle to properly configure Java in R.
I suggest to start with simple Java code:
http://www.owsiak.org/r-java-11-and-making-sure-you-can-load-rjava/
to make sure you can actually use Java inside R.
In some cases it might be required to rebuild rJava package.
http://www.owsiak.org/r-3-4-rjava-macos-and-even-more-mess/
Anyway, I guess that first step is to make sure you can actually bind these two worlds.

Related

Why does not rsubgroup initialize Java?

I am working with R 4.2.1, 64bit, Windows 10.
while calling library rsubgroup, I get an error:
library(rsubgroup)
Loading required package: foreign
Error: package or namespace load failed for ‘rsubgroup’:
.onLoad failed in loadNamespace() for 'rsubgroup', details:
call: .jinit(parameters = parameters)
error: Unable to create a Java class loader.
rJava loads without problems.
I have installed Java 1.8.0_341 and JDK jdk-18.0.2
I have set-up manually JAVA_HOME and PATH variables.
Any hints what can go wrong with .jinit?
many thanks!
Solved, caused by my comp installation: R is installed in C:.../ProgramFiles that is write-protected (accessible only by "admin"); rJava and rsubgroup installed in the ...Users personal library. While moving all installation (core R, libraries) to writable disk, all starts to work. Apologies for this dumb question but I leave it here - perhaps could help somebody in future...

Problems with installing rJava package

I have tried to call the library xlsx, since I want to save data in multiple-sheets excel files, but I got a Java-related error. Even when I run library(rJava) I have this error code:
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/me/Documents/R/win-library/4.0/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
The solutions I have found online are quite old and none helped to solve the issue: I have tried to reinstall Java 64 bit on my OS (Windows 10-64bit), and the package rJava, I have tried to set Java home with Sys.setenv(JAVA_HOME="C:\Program Files\Java\jre1.8.0_271\") without success. I use R 64 bit.
Do you have any suggestions?
Finally, the solution reported here worked for me. The most important thing is to download the offline version of Java

library(rJava) does not load after installing package

I have been reading up on examples and cannot figure out the solution. I also had IT come by and they can't figure out why it isn't working also.
I am trying to use the 'rJava' package from R.
I uninstalled RStudio and R to get the latest versions.
Here is what I did:
install.packages('rJava')
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rJava_0.9-9.zip'
Content type 'application/zip' length 720033 bytes (703 KB)
downloaded 703 KB
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Temp\RtmpSyCpeu\downloaded_packages
Then when I run below, this is what shows up:
library(rJava)
This same error message happens after I uninstalled RStudio and R.
When I click ok, below is the error that comes up.
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/nicknaue/Documents/R/R-
3.4.3/library/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
To try and solve for this, we downloaded the latest Java and also got a file from another program with the same name: jvm.dll and put it in the same file path. No luck also.
Has anyone come across this issue before?
Also, something weird, I have another computer where I tried this on and no errors came up.
I know there have been posts on this but I feel like I have tried everything at this point.
Figured out the answer from this link: Unable to load rJava on R
The issue was that I had 64-bit R and 32 bit Java. The two were not compatible before. You need 64 bit Java in order to run rJava if you have 64 bit R.

Error loading xlsx package

yesterday we migrated to windows 7 in our firm and also updated the java packages and also R (to 2.14).
Then I tried to load the xlsx package, because I rely heavly on it but i get the following error:
Error : .onAttach in attachNamespace()
Error: .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")
I tried the following, but it did not work:
Sys.setenv(PATH=paste(Sys.getenv("PATH"),"C:\\Program Files (x86)\\Java\\jre6\\bin\\client",collapse=';'))
options(java.parameters = "-Xmx1000m")
Since I never work with java i have no clue what I can do. Can you help me?
Thank you!
sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252
[3] LC_MONETARY=German_Austria.1252 LC_NUMERIC=C
[5] LC_TIME=German_Austria.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] xlsxjars_0.4.0 rJava_0.9-3
loaded via a namespace (and not attached):
[1] tools_2.14.1 xlsx_0.4.2
The interesting thing is, that the package XLConnect loads without problems.EDIT: Ok, it loads without problems but loading a workbook does not work:
Error: NoSuchMethodError (Java): org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions;
So maybe it is really no Java problem. But I don't want to re-write all my code to XLConnect!
Nobody any ideas what I could try?
I encountered exactly the same error and found a work-around. If you specify a library location on the network to install the package into, the error occurs.
## Example where error occurs:
install.packages('xlsx', lib='\\network\R\library')
library('xlsx', lib='\\network\R\library'))
However, if you change the default location for package installation within R, then you should be able to call the package library without the error. That is, simply typing install.packages('xlsx'), and having the package install automatically to its default location, allowed the package to work properly.

Installing PL/Java on MAC

I’m really having trouble installing Pl/Java on Mac, any help would be appreciated.
I’ll describe the exact steps I’ve done in accordance with the README here, but I still get some errors that I cannot resolve.
(1) I’ve downloaded this version: pljava-i686-pc-linux-gnu-pg9.0-1.4.2
(2) I’ve located three files in the directory: pljava.jar, deploy.jar, pljava.so
(3) I’ve put the two .jars inside: /Library/PostgreSQL/9.0/lib
(4) I’ve put the .so inside: /Library/PostgreSQL/9.0/data
(5) I’ve modified the postgresql.conf as follows:
dynamic_library_path = '$libdir'
custom_variable_classes = 'pljava'
pljava.classpath = '/Library/PostgreSQL/9.0/lib/pljava.jar’
(6) I’ve also tried:
dynamic_library_path = '$libdir:/Library/PostgreSQL/9.0/lib/' (as well as...)
dynamic_library_path = '$libdir:/Library/PostgreSQL/9.0/data/'
(7) I then try to run:
Select sqlj.install_jar('/Software/Libraries/test_trigger.jar', 'samples', false);
Select sqlj.set_classpath(‘public’, ‘samples’);
Although, I keep getting this error:
WARNING: java.lang.NoSuchMethodError: Method org.postgresql.pljava.internal.Portal._fetch(JZI)I not found
ERROR: Unable to register native methods
********** Error **********
ERROR: Unable to register native methods
SQL state: XX000
This sounds like an issue is in not loading the right .jar. You mentioned in your comments that you were also having a problem with appropriate environment variables specifying where to load modules. This may in fact be your main issue. It looks like the equivalent environment variable is DYLD_LIBRARY_PATH though you can get more options by looking at man dyld and obviously if you are loading the wrong .so or .jar you will get errors like this.

Categories