Using the rJava package on Win7 64 bit with R - r

I'm trying to install rJava on a computer with Win 7 64 bit. When I run
install.packages("rJava")
everything seems to be fine:
Installing package(s) into ‘C:/Users/djq/Documents/R/win-library/2.13’
(as ‘lib’ is unspecified)
trying URL 'http://software.rc.fas.harvard.edu/mirrors/R/bin/windows/contrib/2.13/rJava_0.9-1.zip'
Content type 'application/zip' length 654936 bytes (639 Kb)
opened URL
downloaded 639 Kb
package 'rJava' successfully unpacked and MD5 sums checked
The downloaded packages are in
C:\TEMP\RtmpW2eAUw\downloaded_packages
but when I tried to load the library library(rJava) I get the following error:
Error : .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/2.13/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Error: package/namespace load failed for 'rJava'
I have installed the Java JRE (trying both 32 and 64 bit versions) and the JDK (using both 32 and 64 bit). My R version is R version 2.13.1 (2011-07-08) and I'm using RStudio.
If I try using 32 bit R, I can load rJava fine. Is the problem just that rJava does not run in R 64 bit? How can I tell if a package is just for 32 instead of 64?
edit: just posted R.version():
> R.Version()
$platform
[1] "x86_64-pc-mingw32"
$arch
[1] "x86_64"
$os
[1] "mingw32"
$system
[1] "x86_64, mingw32"
$status
[1] ""
$major
[1] "2"
$minor
[1] "13.1"
$year
[1] "2011"
$month
[1] "07"
$day
[1] "08"
$`svn rev`
[1] "56322"
$language
[1] "R"
$version.string
[1] "R version 2.13.1 (2011-07-08)"

Update (July 2018):
The latest CRAN version of rJava will find the jvm.dll automatically, without manually setting the PATH or JAVA_HOME. However note that:
To use rJava in 32-bit R, you need Java for Windows x86
To use rJava in 64-bit R, you need Java for Windows x64
To build or check R packages with multi-arch (the default) you need to install both Java For Windows x64 as well as Java for Windows x86. On Win 64, the former installs in C:\Program files\Java\ and the latter in C:\Program Files (x86)\Java\ so they do not conflict.
As of Java version 9, support for x86 (win32) has been discontinued. Hence the latest working multi-arch setup is to install both jdk-8u172-windows-i586.exe and jdk-8u172-windows-x64.exe and then the binary package from CRAN:
install.packages("rJava")
The binary package from CRAN should pick up on the jvm by itself. Experts only: to build rJava from source, you need the --merge-multiarch flag:
install.packages('rJava', type = 'source', INSTALL_opts='--merge-multiarch')
Old anwser:
(Note: many of folks in other answers/comments have said to remove JAVA_HOME, so consider that. I have not revisited this issue recently to know if all the steps below are still necessary.)
Here is some quick advice on how to get up and running with R + rJava on Windows 7 64bit. There are several possibilities, but most have fatal flaws. Here is what worked for me:
Add jvm.dll to your PATH
rJava, the R<->Java bridge, will need jvm.dll, but R will have trouble finding that DLL. It resides in a folder like
C:\Program Files\Java\jdk1.6.0_25\jre\bin\server
or
C:\Program Files\Java\jre6\jre\bin\client
Wherever yours is, add that directory to your windows PATH variable. (Windows -> "Path" -> "Edit environment variables to for your account" -> PATH -> edit the value.)
You may already have Java on your PATH. If so you should find the client/server directory in the same Java "home" dir as the one already on your PATH.
To be safe, make sure your architectures match.If you have Java in Program Files, it is 64-bit, so you ought to run R64. If you have Java in Program Files (x86), that's 32-bit, so you use plain 32-bit R.
Re-launch R from the Windows Menu
If R is running, quit.
From the Start Menu , Start R / RGUI, RStudio. This is very important, to make R pick up your PATH changes.
Install rJava 0.9.2.
Earlier versions do not work! Mirrors are not up-to-date, so go to the source at www.rforge.net: http://www.rforge.net/rJava/files/. Note the advice there
“Please use
`install.packages('rJava',,'http://www.rforge.net/')`
to install.”
That is almost correct. This actually works:
install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/')
Watch the punctuation! The mysterious “.libPaths()[1],” just tells R to install the package in the primary library directory. For some reason, leaving the value blank doesn’t work, even though it should default.

Getting rJava to work depends heavily on your computers configuration:
You have to use the same 32bit or 64bit version for both: R and JDK/JRE. A mixture of this will never work (at least for me).
If you use 64bit version make sure, that you do not set JAVA_HOME as a enviorment variable. If this variable is set, rJava will not work for whatever reason (at least for me). You can check easily within R is JAVA_HOME is set with
Sys.getenv("JAVA_HOME")
If you need to have JAVA_HOME set (e.g. you need it for maven or something else), you could deactivate it within your R-session with the following code before loading rJava:
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
This should do the trick in most cases. Furthermore this will fix issue Using the rJava package on Win7 64 bit with R, too. I borrowed the idea of unsetting the enviorment variable from R: rJava package install failing.

For me, setting JAVA_HOME did the trick (instead of unsetting, as in another answer given here). Either in Windows:
set JAVA_HOME="C:\Program Files\Java\jre7\"
Or inside R:
Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jre7\\")
But what's probably the best solution (since rJava 0.9-4) is overriding within R the Windows JAVA_HOME setting altogether:
options(java.home="C:\\Program Files\\Java\\jre7\\")
library(rJava)

The last question has an easy answer:
> .Machine$sizeof.pointer
[1] 8
Meaning I am running R64. If I were running 32 bit R it would return 4. Just because you are running a 64 bit OS does not mean you will be running 64 bit R, and from the error message it appears you are not.
EDIT: If the package has binaries, then they are in separate directories. The specifics will depend on the OS. Notice that your LoadLibrary error occurred when it attempted to find the dll in ...rJava/libs/x64/... On my MacOS system the ...rJava/libs/...` folder has 3 subdirectories: i386, ppc, and x86_64. (The ppc files are obviously useless baggage.)

Sorry for necro.
I have too run into the same issue and found out that rJava expects JAVA_HOME to point to JRE. If you have JDK installed, most probably your JAVA_HOME points to JDK. My quick solution:
Sys.setenv(JAVA_HOME=paste(Sys.getenv("JAVA_HOME"), "jre", sep="\\"))

I had a related problem with rJava. It would load but a package that depends on it, would not load.
Users may waste a lot of time with jvm.dll and PATH and JAVA_HOME when the real fix is to force the installer to just forget about i386. Use option for install.packages. (this also works when drat library is used. (credit goes to Dason)
install.packages("SqlRender",INSTALL_opts="--no-multiarch")
Also, you can modify just your user path with a win command like this:
setx PATH "C:\Program Files\Java\jre1.8.0_102\bin\server;%PATH%"

I had some trouble determining the Java package that was installed when I ran into this problem, since the previous answers didn't exactly work for me. To sort it out, I typed:
Sys.setenv(JAVA_HOME="C:/Program Files/Java/
and then hit tab and the two suggested directories were "jre1.8.0_31/" and "jre7/"
Jre7 didn't solve my problem, but jre1.8.0_31/ did. Final answer was running (before library(rJava)):
Sys.setenv(JAVA_HOME="C:/Program Files/Java/jre1.8.0_31/")
I'm using 64-bit Windows 8.1 Hope this helps someone else.
Update:
Check your version to determine what X should be (mine has changed several times since this post):
Sys.setenv(JAVA_HOME="C:/Program Files/Java/jre1.8.0_x/")

Download Java from https://java.com/en/download/windows-64bit.jsp for 64-bit windows\Install it
Download Java development kit from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html for 64-bit windows\install it
Then right click on “This PC” icon in desktop\Properties\Advanced system settings\Advanced\Environment Variables\Under System variables select Path\Click Edit\Click on New\Copy and paste paths “C:\Program Files\Java\jdk1.8.0_201\bin” and “C:\Program Files\Java\jre1.8.0_201\bin” (without quote) \OK\OK\OK
Note: jdk1.8.0_201 and jre1.8.0_201 will be changed depending on the version of Java development kit and Java
In Environment Variables window go to User variables for User\Click on New\Put Variable name as “JAVA_HOME” and Variable value as “C:\Program Files\Java\jdk1.8.0_201\bin”\Press OK
To check the installation, open CMD\Type javac\Press Enter and Type java\press enter It will show
In RStudio run
Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jdk1.8.0_201")
Note: jdk1.8.0_201 will be changed depending on the version of Java development kit
Now you can install and load rJava package without any problem.

I need to have a 32 bit JRE available for my browser, but 64 bit JRE for R and rJava. The 32 bit JRE is installed in the default location. After some experimentation, I found that I only needed one of misterbee's suggestions to get rJava (version 0.9-6) working for me. All I did was add the path to my 64 bit java installation:
C:\apps\Java\jre\bin\server\jvm.dll
to the top of my path environment variable (your path will likely be different) and remove my JAVA_HOME as user2161065 suggested. I put this just ahead of the entry
C:\ProgramData\Oracle\Java\javapath
which the Oracle installer inserts at the top of the path and points to some symlinks to the 32 bit JRE. By adding the entry to 64 bit jvm.dll, looks like rJava could find what it needs.

I think this is an update. I was unable to install rJava (on Windows) until I installed the JDK, as per
Javac is not found
and
javac not working in windows command prompt. The message I was getting was
'javac' is not recognized as an internal or external command, operable program or batch file.
The JDK includes the JRE, and according to
https://cran.r-project.org/web/packages/rJava/index.html
the current version (0.9-7 published 2015-Jul-29)
of rJava
SystemRequirements: Java JDK 1.2 or higher (for JRI/REngine JDK 1.4 or higher), GNU make
So there you are: if rJava won't install because it can't find javac, and you have the JRE installed, then try the JDK. Also, make sure that JAVA_HOME points to the JDK and not the JRE.

I solved the issue by uninstalling apparently redundant Java software from my windows 7 x64 machine. I achieved this by first uninstalling all Java applications and then installing a fresh Java version. (Later I pointed R 3.4.3 x86_64-w64-mingw32 to the Java path, just to mention though I don't think this was the real issue.) Today only Java 8 Update 161 (64-bit) 8.0.1610.12 was left then. After this, install.packages("rJava"); library(rJava) did work perfectly.

This is a follow-up to Update (July 2018). I am on 64 bit Windows 10 but am set up to build r packages from source for both 32 and 64 bit with Rtools. My 64 bit jdk is jdk-11.0.2. When I can, I do everything in RStudio. As of March 2019, rjava is tested with <=jdk11, see github issue #157.
Install jdks to their default location per Update (July 2018) by #Jeroen.
In R studio, set JAVA_HOME to the 64 bit jdk
Sys.setenv(JAVA_HOME="C:/Program Files/Java/jdk-11.0.2")
Optionally check your environmental variable
Sys.getenv("JAVA_HOME")
Install the package per the github page recommendation
install.packages("rJava",,"http://rforge.net")
FYI, the rstudio scripting console doesn't like the double commas... but it works!

So many answers and yet, nothing worked for me - very disappointing and frustrating.
Every now and then I will run into this issue and waste time on Google.
So here is what DID work for me, I am on Windows 10, with everything fully updated.
I went here to download JDK and JRE 8u301, the latest version at this writing.
Oracle Latest Java Download Link
Note I had to create an account or log into my account - takes no time and is free, nothing to worry about.
I installed JRE and then JDK, using the exe just downloaded in the previous step.
In Rstudio (or in R), I ran Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk1.8.0_301').
Running install.packages("rJava") led to the desired DONE (rJava). (of course, I assume you also have Rtools installed, goes without saying...)
Pretty simple and easy imho.
With the right steps, took me 3 min.

Related

Exporting excel files from R in windows [duplicate]

I am trying to load the rJava using the command:
library(rJava)
But I get the following error:
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package or namespace load failed for ‘rJava’
I tried reinstalling both the Java and the R program with the latest versions
but still get these errors..
May I know how I can resolve this? Thank you very much!
This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.
http://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/
Install 64 bit Java from https://java.com/en/download/manual.jsp.
Then in windows cmd run
setx PATH "C:\Program Files\Java\jre1.8.0_211\bin\server;%PATH%"
(make sure your path is correct).
Then in RStudio run
Sys.setenv(JAVA_HOME="")
Now, you should be able to run rJava!!
I got the same error resolved by installing same version of R and Java i.e. 64 bits and manually updating the path i.e. ,
Sys.setenv(JAVA_HOME='C:/Program Files/Java/jre1.8.0_121') # for 64-bit version
R for Windows installer installs by default both 32-bit and 64-bit files. Reinstalling R and unticking 32-bit part solved the problem for me.
Under Windows 10, first check your (running) R-Version:
R.version
If you see something like x86_64, a 64-bit version of Java is needed.
Simply downloading and installing the matching Java version (https://java.com/en/download/manual.jsp) solved the problem for me. No reinstall of R needed (as suggested by other users here). There also was no need to set the path explicitly.
As mentioned in the r-statistics link cited above, you have to manually download the 64-bit version of Java. If not, then the 32-bit version will be installed.
So, if you have a 64-bit operating system, then ensure that both R and Java are using the 64-bit installs. Otherwise, this problem will persist.
This has been killing me and I have tried multiple methods above, it doesn't work. After, I mix all solution to try and below process works for me.
Install Java for 64 bit
Run below code in windows command
setx PATH "C:\Program Files\Java\jre1.8.0_171\bin\server;%PATH%"
(please change the address acorrding to your dvm.dll real address)
Run below in R studio
Sys.setenv(JAVA_HOME="")
Then I finally can run
library(rJava)
library(xlsx)
I faced the same issue and was feeling very down as I couldnt get my analysis done.
This worked for me :
check your operating system. 64 bit or 32 bit.
https://helpx.adobe.com/x-productkb/global/determine-whether-computer-running-32.html
uninstall previous versions of Java.
delete rJAVA library from Doc>R>win-library. If you have more than 1 versions of R, make sure you delete rJAVA package from all of them.
install Java based on system requirement (64 bit or 32 bit).
and finally restart R before and after installing rJava package.
If R is 64-bit version make sure to install Java 64-bit version!
If R is x86-bit version make sure to install Java x86-bit version!
You can add INSTALL_opts=c("--no-multiarch") to your install_github() call:
devtools::install_github("mne-tools/mne-r", INSTALL_opts=c("--no-multiarch"))
For more info: https://github.com/mne-tools/mne-r/issues/5#issuecomment-489588267
Create a new directory in C: drive as "library"
set your libPath this directory. you need to type
.libPath("C:/library")
reinstall packages which requires java (xlsx, rJava, RJDemetra)
it will give error message again but it will work.

Although the xlsx package is installed in R, it does not work

Although the xlsx package is installed, it does not work.
I get the following error. What should I do? I use the latest version of R
install.packages("xlsx")
Installing package into ‘C:/Users/Cgdm/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/xlsx_0.6.5.zip'
Content type 'application/zip' length 374910 bytes (366 KB)
downloaded 366 KB
package ‘xlsx’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Cgdm\AppData\Local\Temp\RtmpCy2Eng\downloaded_packages
library(xlsx)
Error: package or namespace load failed for ‘xlsx’:
onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Common Problems -- Java and xlsx package
R users who have not previously used packages that rely on Java often have problems when attempting to use the xlsx package that is used to read Excel spreadsheets.
Java runtime not installed
First, many new R users have not previously needed to install a Java runtime on their computers. The xlsx package depends on the rJava and xlsxjars packages. rJava requires the Java Runtime Environment 1.2 or above to also be present on one's computer.
Solution 1: Use an excel reader package that doesn't require Java
PRO TIP: The easiest way to work around this problem is to use an R package that does not depend on Java, such as openxlsx or readxl.
For openxlsx, it's very easy.
install.packages("openxlsx")
library(openxlsx)
# read the help file to identify the arguments needed to
# correctly read the file
?openxlsx
theData <- read.xlsx(...)
The same process can be used for readxl.
install.packages("readxl")
library(readxl)
# read the help file to identify the arguments needed to
# correctly read the file
?readxl
theData <- read_excel(...)
Solution 2: Install Java and required R packages
That said, for people who still want to use the xlsx package, there are workable solutions for Windows, Mac OSX, and Ubuntu Linux.
SOLUTION (Windows): Download and install the latest version of the Java Runtime Environment from Oracle. Note that if you are running the 64-bit version of R, you need to install the 64-bit version of the Java Runtime.
SOLUTION (Mac OSX): As of newer releases of Mac OSX, this has become more complicated. A specific set of commands needs to be followed after installing the Java Development Kit on the computer. These are documented on the rJava Issue 86 github page.
SOLUTION (Ubuntu): Use the Ubuntu Advanced Packaging Tool to install Java, then reconfigure Java in R.
sudo apt-get install openjdk-8-jdk # openjdk-9-jdk has some installation issues
sudo R CMD javareconf
Then in R / RStudio install the xlsx package.
install.packages("xlsx")
32-bit vs. 64-bit Java in Windows
Another common problem people may encounter is an incompatibility between the version of the Java Runtime Environment that is installed on their computer and the version of R, either 32-bit or 64-bit.
For example, if one has installed the 64-bit version of R but has the 32-bit version of Java Runtime Environment installed, R will not have visibility to the Java Runtime Environment, generating the same "Java not installed error" as noted above.
SOLUTION: This problem can be resolved by either installing the 64-bit version of Java Runtime for Windows, or by changing the RStudio configuration to use the 32-bit version of R.
One can identify the version of Java that is installed, and whether it is 32 or 64-bit, by executing the following function within R / RStudio.
system("java -version")
...which on a Windows-based PC will return something like this.
Extracting Java settings from Windows registry
Another approach to validating the version of Java that is installed on a Windows-based machine is to use utils::readRegistry() (h/t Access Windows Registry inside R).
readRegistry("SOFTWARE\\JavaSoft\\Java Runtime Environment","HLM",maxdepth=3)
returns the following:
> readRegistry("SOFTWARE\\JavaSoft\\Java Runtime Environment","HLM",maxdepth=3)
$BrowserJavaVersion
[1] "11.261.2"
$CurrentVersion
[1] "1.8"
$`1.8`
$`1.8`$JavaHome
[1] "C:\\Program Files\\Java\\jre1.8.0_261"
$`1.8`$MicroVersion
[1] "0"
$`1.8`$RuntimeLib
[1] "C:\\Program Files\\Java\\jre1.8.0_261\\bin\\server\\jvm.dll"
$`1.8.0_261`
$`1.8.0_261`$JavaHome
[1] "C:\\Program Files\\Java\\jre1.8.0_261"
$`1.8.0_261`$MicroVersion
[1] "0"
$`1.8.0_261`$RuntimeLib
[1] "C:\\Program Files\\Java\\jre1.8.0_261\\bin\\server\\jvm.dll"
$`1.8.0_261`$MSI
$`1.8.0_261`$MSI$AUTOUPDATECHECK
[1] "1"
$`1.8.0_261`$MSI$AUTOUPDATEDELAY
[1] ""
$`1.8.0_261`$MSI$EULA
[1] ""
$`1.8.0_261`$MSI$FROMVERSION
[1] "NA"
$`1.8.0_261`$MSI$FROMVERSIONFULL
[1] ""
$`1.8.0_261`$MSI$FullVersion
[1] "1.8.0_261-b12"
$`1.8.0_261`$MSI$INSTALLDIR
[1] "C:\\Program Files\\Java\\jre1.8.0_261\\"
$`1.8.0_261`$MSI$JAVAUPDATE
[1] "1"
$`1.8.0_261`$MSI$JU
[1] ""
$`1.8.0_261`$MSI$OEMUPDATE
[1] ""
$`1.8.0_261`$MSI$PRODUCTVERSION
[1] "8.0.2610.12"
This is a lot of output, but we can still see that the current version of Java is 1.8, and the JavaHome setting is C:\\Program Files\\Java\\jre1.8.0_261. Since the registry tree is relatively complicated, it takes a fair amount of knowledge to write the correct key to reduce the amount of output returned.
# more specific extract, given that $CurrentVersion is 1.8
readRegistry("SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.8","HLM",maxdepth=3)
...returns a more targeted set of registry settings.
> readRegistry("SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.8","HLM",maxdepth=3)
$JavaHome
[1] "C:\\Program Files\\Java\\jre1.8.0_261"
$MicroVersion
[1] "0"
$RuntimeLib
[1] "C:\\Program Files\\Java\\jre1.8.0_261\\bin\\server\\jvm.dll"
Java / R compatibility with non-English versions of Windows 10
Note that as of July 2020, users on Stackoverflow.com have reported problems installing Java and rJava in the scenario where the version of Windows is a non-English language version (e.g. Chinese, Polish, etc.). It appears that the way the Java installer works with these versions of Windows, R and the rJava package are not able to access the JAVA_HOME directory correctly.
To correct the problem, reinstall R with the same language used by Windows. That is, on the Chinese version of Windows, install R with Chinese langauge support. Once installed, you can change the language to English by setting language = "en" in the .Rconsole file.
Reference: Common Problems: Java and xlsx package, originally posted by me on my Johns Hopkins Data Science Specialization Community Mentor Repository, January 2017.
It seems that your JAVA_HOME is not configured correctly, hence
from https://www.rdocumentation.org/packages/xlsx:
"Ensure that the system environment variable JAVA_HOME is configured appropriately and points to your jdk of choice. Typically, this will be included in your PATH environment variable as well. Options and system environmental variables that are available from R can be seen with Sys.getenv()."
Check your config by doing
d <- Sys.getenv()
d[names(d) == "JAVA_HOME"]
It should point to your Java installation, e.g. "C:\Program Files\Java\jdk1.8.0_104"
On Windows 10, this can be set in "Advanced System Settings, System Properties, Environment Variables"

Building package using RcppArmadillo on 64bit Windows

I have been using RcppArmadillo to build a package, but I've run into a small problem. I have a perfectly working package for 32-bit R, but I would like for it to run on 64-bit. When I started working on the package I was using 32-bit R (without realizing it), but when I shifted to 64-bit R I stopped being able to build my package. I get the error saying "LoadLibrary failure: %1 is not a valid Win32 application."
I realize that the issue is that the .dll file is 32-bit so 64-bit R can't work with it. What I don't understand is how to recreate the .dll so that it is 64-bit. In 64-bit R when I run devtools::find_rtools() I get TRUE, so I suspect that I have to add something to the makevars files to make this work.
So my question in one sentence is: how do you get a working 32bit package with RcppArmadillo to work with 64bit on Windows? Any guidance would be greatly appreciated.
All CRAN packages build on 32 and 64 bit Windows.
All CRAN submissions, including my different Rcpp* packages do (apart from those requiring Unix, or C++11, or ...).
So if I were you, and had (temporary) troubles setting up my main box, I would still use the excellent win-builder which will generate 32 and 64 bit binaries for you.
Aha, it was the makevars files.
I had to add $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")

JavaGD fails to load

Could someone please help.
I had Deducer working with R 2.14 but now that I have updated to 2.15.1 I can't get JGR to load. I have loaded JGR and Deducer.
This is the message I get when installing
Loading required package: JavaGD
Error : .onLoad failed in loadNamespace() for 'JavaGD', details:
call: .Call("RegGetStrValue", c(key, "CurrentVersion"), PACKAGE = "JavaGD")
error: C symbol name "RegGetStrValue" not in DLL for package "JavaGD"
Error: package ‘JavaGD’ could not be loaded
I have removed all old versions of R and Ver 2.15.1 - reinstalled R and still get this message.
Is it possible that this is a Registry problem and if so where should I look.
I have searched and although there seem to be simiar reported issues, none are exactly the same from the ones that I have seen. I certainly dont seem to have m,ultiple versions of JavaGD in my library and the Namesake file is in the folder JavaGD.
I am running Win 7 32 bit ver on fairly current Dell Laptop.
R seems to work fine and I am using R-Studio most of the time and that works fine as well.
Any help would be appreciated
7 years on form the OP's original issue choosing the right Java Download is critical for 64-bit machines which most of our RStudio environments are synced to work with. For whatever reason, downloading the 64-bit JRE is difficult. To avoid the same error presented by Deducer more recently be sure to download the 64-bit Java JRE from https://www.java.com/en/download/manual.jsp. Note, the 64-bit version must be downloaded offline as instructed (usually bottom of Windows downloads). Check that the installation path is c:\Program Files\Java and not c:\Program Files(x86)\Java. That plus the JDK should fix this problem going forward.

qpdf.exe for compactPDF?

I am trying to check a package that I have built (with vignette) using R CMD check --as-cran [my package] in my windows command prompt. All goes well until I get the message,
WARNING 'qpdf' is needed for checks on size reduction of PDFs
I have downloaded qpdf, put the unzipped folder in my program files directory, and added the bin folder to the PATH.
Not quite sure what else I need to do? I have the feeling I have not installed qpdf correctly or I need to build this program itself? I have read through the readme files and manual for qpdf which appear to be more aimed at unix users (which I have no experience with... I am your standard/regular windows user with little to no programming experience outside of statistical languages). I have had a go at trying to build qpdf using cgywin, but ended up failing to install zlib and prec. Any tips?
I would try
Sys.which(Sys.getenv("R_QPDF", "qpdf"))
Sys.getenv("PATH")
to establish that R is really not finding the qpdf executable, and see where it is looking. You probably shouldn't need to rebuild everything, just figure out why R is not finding the qpdf executable ... does running qpdf from a terminal window work ... ? How are you starting R, and did it have a chance to get the new PATH definition (i.e. do you need to open a new terminal window, or ?? reboot ??)
The incantation above was extracted from tools::compactPDF, from the default value of the qpdf argument, on a Linux machine. You should check for yourself, in case (e.g.) the Windows version is looking for qpdf.exe rather than qpdf ...
There are a couple of other things to consider on a Windows machine:
If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 7.0 is listed here).
Once you have extracted the zipped qpdf directory to your hard disk, perhaps under C:\Program Files\, added C:\Program Files\qpdf-version_number\bin to your system PATH under the environment variables, and re-launched R, Windows needs to establish that pqdf is safe to run.
Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning, as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.
Recent developments: If you install Rtools 3.5 qpdf is included and that warning is gone. Rtools is a toolset for building packages on Windows and is recently reworked by Jeroen Ooms.
More information : https://cran.r-project.org/bin/windows/Rtools/
Note that the changelog is incomplete, as Rtools 3.5 isn't frozen yet at the time of writing (2019-03-01). Even though it's not visible on the page yet, qpdf.exe is included in the bin directory after installation.
After installing the latest version of RTools, the warning still popped up.
However, I noticed that the Windows "where" command gave two paths to qpdf (different versions). After removing the R_QPDF environment variable and removing the new install of qpdf from the Windows path, so that only qpdf in RTools was found, the warning disappeared.
I got the same warning on Ubuntu so here's a Ubuntu solution for completeness:
First update packages
sudo apt update
Then install qpdf with
sudo apt install qpdf
Tested on Ubuntu 20.04.

Resources