Check out the package and team website for more details and documentations: openVA.net
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 ingredients: R, and Java. Here is how you can make sure you have the right combination of the two:
java -version
. If Java is installed, it will show the Java version number. Version number at least 1.7.x should be sufficient.java -version
on terminal or Command Prompt. It should show the correct version number just installed.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, lizehang@uw.edu) 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')
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)
```
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
```
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")
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
```
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)
```
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"
.
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