Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing R package openNLP in R

Tags:

java

r

opennlp

I am trying to install openNLP package in R (mac) and keep getting the following error message

> install.packages("openNLP")
trying URL 'https://rweb.crmda.ku.edu/cran/bin/macosx/mavericks/contrib/3.2/openNLP_0.2-6.tgz'
Content type 'application/x-gzip' length 32952 bytes (32 KB)
==================================================
downloaded 32 KB


The downloaded binary packages are in
    /var/folders/20/gzm2zpr94pz9dghqd8l5ff1c0000gn/T//Rtmp8n5kNw/downloaded_packages
> library(openNLP)
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.
Error : .onLoad failed in loadNamespace() for 'openNLPdata', details:
  call: .jinit()
  error: JNI_GetCreatedJavaVMs returned -1

Error: package or namespace load failed for ‘openNLP’


Here is my R version

> R.Version()

$platform
[1] "x86_64-apple-darwin13.4.0"

$arch
[1] "x86_64"

$os
[1] "darwin13.4.0"

$system
[1] "x86_64, darwin13.4.0"

$status
[1] ""

$major
[1] "3"

$minor
[1] "2.4"

$year
[1] "2016"

$month
[1] "03"

$day
[1] "10"

$`svn rev`
[1] "70301"

$language
[1] "R"

$version.string
[1] "R version 3.2.4 (2016-03-10)"

$nickname
[1] "Very Secure Dishes"

I have Java installed

java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

rJava is also installed. Any help would be much appreciated

like image 305
Ashin Mukherjee Avatar asked May 03 '16 21:05

Ashin Mukherjee


1 Answers

Proposed Solution:

1. Launch R at the command line (To test solution)

> sudo R CMD javareconf
> export LD_LIBRARY_PATH=$JAVA_LD_LIBRARY_PATH
> LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio

now within RStduio:

> install.packages("rJava", type = "source")
> install.packages("openNLP")
> require(rJava)
> require(openNLP)

To launch RStudio from finder... (El Capitan)

You have to link libjvm.dylib to /usr/lib...

sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

now launch via finder...

Detailed Explanation:

rJava load error in RStudio/R after "upgrading" to OSX Yosemite

like image 123
Technophobe01 Avatar answered Sep 17 '22 08:09

Technophobe01