This guide presents an overview for installing openVA package, with some common error reports and solutions at the end.
Whenever the openVA package is loaded to R, it also requires four other core packages on CRAN for each of the VA coding methods, namely, InSilicoVA, InterVA4, Tariff, and nbc4va, and ggplot2 for visualization. Additionally, the InSilicoVA package further requires the dependency of coda and rJava for its computation.
Users typically need to take no specific action regarding the dependencies, since R takes care of them automatically. However, sometimes issues with installing openVA package can arise because of some of the dependencies, which may require additional configurations and re-installing the package. I find that most of the times, the errors stem from loading rJava, and thus is the main focus of this guide.
As the name suggests, to properly load the package rJava, you will need two key ingradients: R, and Java. Here is how you can make sure you have the right combination of the two:
- If you do not aleady have it, install from CRAN. Follow the instructions at the link to choose a mirror that will take you to the download page. After download, double click the file to install.
- Open R. On the welcome message, there is a line starting with “Platform” and ending with “(32-bit)” or “(64-bit)”. It is very important to know which version (32-bit or 64-bit) of R you use, since the Java JDK should have the same version.
- Sometimes multiple versions of R could be installed on the same machine, so you should check the version you wish to use for data analysis. For example, if you prefer using RStudio to run the codes, you should check the default R version of RStudio by reading the welcome message for RStudio, instead of, say, the R version when opening from command line.
- To check if Java in installed on your Mac or Linux machine, open terminal if you use Mac or Linux and type in
java -version
. If Java is installed, it will show the Java version number. Version number at least 1.7.x should be sufficient. - To check if Java is installed on your Windows machine, open Control Panel, select Programs, then select Programs and Features, and see if Java is listed.
- If no Java is installed (on Mac OSX, you will see a pop-up notice of installing Java JDK), or version too low, you should download and install a newer Java JDK by following the instructions at http://www.oracle.com/technetwork/java/javase/downloads/index.html. On that page, there are downloads for both “Java SE 8uXX” and “Java SE 7uXX” (XX is the specific most recent re- leased subversion number), which stands for Standard Edition Java 8 and 7. The required download is JDK (Java Development Kit). Click on download link for JDK and choose the appropriate version. You should choose “x86” version if your R version is 32-bit, and “x64” if R is 64-bit. Then follow the instructions to finish download and install Java.
- After successfully installing Java, try again typing
java -version
on terminal or Command Prompt. It should show the correct version number just installed.
- For users not familiar with R envrionment, see the official introduction.
- Many people find using R from Rstudio to be more convenient. Rstudio could be downloaded from its website.
Here I include some tips of installing and loading rJava package that I found to be useful in the past. Some of those here have been fixed in later version so the solutions might be out-dated.
If you encounter other errors not listed here, or could not resolve the errors following the steps listed, or would like to propose new solutions, you are more than welcome to contact me (Richard Li, [email protected]) or submit issue reports to this Github repository. If you know explicitly the errors are caused by rJava, you could also submit issue reports to the rJava repository directly.
Here is the things you might see down the rabbit hole - One thing omitted in the tricks is that typically for most of the tricks below (for Mac and Linux system especially, I found Windows machine usually does not need this), at the end, it requires another step of re-compiling rJava from source, i.e., adding the type='source'
as below:
install.packages('rJava', type='source')
- Fail to load rJava on Mac OSX (El Capitan 10.11): original post
-
Example Error Message:
``` JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib Java FATAL: Failed to load the jvm library. Error : .onLoad failed in loadNamespace() for 'InSilicoVA', details: call: .jinit() error: JNI_GetCreatedJavaVMs returned -1 ```
-
Solution: Open terminal and execute the commands:
``` sudo R CMD javareconf ```
Then reopen R and run
```
install.packages("rJava", type = "source")
library(openVA)
```
- Fail to install rJava (usually from Rstudio): original post
-
Example Error Message:
``` ERROR: configuration failed for package ‘rJava’ * removing ‘....some directory.../rJava’ Warning in install.packages : installation of package ‘rJava’ had non-zero exit status ```
-
Solution: Open terminal and execute the commands:
``` sudo R CMD javareconf ```
- Fail to install rJava (version 0.9-10, May 2018) on Mac original issue:
- Example Error Message:
checking whether /usr/bin/javah actually works... no checking whether javah was replaced by javac -h... no configure: error: one or more Java tools are missing. JDK is incomplete! Please make sure you have a complete JDK. JRE is not sufficient. configure: error: ./configure failed for jri ERROR: configuration failed for package 'rJava'
- Solution: This is a temporary solution by installing the older version of rJava to get around the unrecognized javah command:
install.packages("https://cran.r-project.org/src/contrib/Archive/rJava/rJava_0.9-9.tar.gz")
- Fail to load rJava on Mac: original post
-
Example Error Message:
-
Solution: This is a common problem whenever your Mac OS gets updated, especially if you use Rstudio. As of OSX El Capitan 10.11, the trick that seems to work for me is to run the following from terminal:
``` sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib ```
- Failure to load rJava on 64-bit Windows: original post
-
Example Error Message:
``` Error : .onLoad failed in loadNamespace() for 'rJava', details: call: inDL(x, as.logical(local), as.logical(now), ...) ```
-
Solution: This is only useful when rJava package can be installed (
install.packages("rJava")
), but not loaded (library('rJava')
). Sometimes it works by executing the following in R console:``` if (Sys.getenv("JAVA_HOME")!="") Sys.setenv(JAVA_HOME="") library(rJava) ```
- Failure to install rJava on Windows with
type = "source"
.
-
Example Error Message:
``` Warning: running command 'sh ./configure.win' had status 127 ERROR: configuration failed for package 'rJava' ```
-
Solution: (1) Check java path is in the system environmental variable list (on Win 10, click Windows icon and type "environmental"), (2) Try re-install without
type = "source"
.
- Failure to install rJava on Linux: original post
-
Example Error Message:
``` checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this. ERROR: configuration failed for package ‘rJava’ ```
-
Solution:
apt-get install r-cran-rjava
- More misc error messages and hacks that I have not tried myself:
- OSX + Rstudio 1
- OSX + Rstudio 2
- OSX + Rstudio 3
- OSX + Rstudio 4
- Windows + registry
- No Java run time in OSX (with many useful discussions)