0

I'm working with R on Ubuntu, I want to use the CoreNLP package and I have a weird behaviour. When I use a shell, everything is fine, for instance I can run:

$ R

R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> library(rjava)
Error in library(rjava) : there is no package called ‘rjava’
> library(rJava)
> library(coreNLP)
> initCoreNLP()
Searching for resource: config.properties
Adding annotator tokenize
TokenizerAnnotator: No tokenizer type provided. Defaulting to PTBTokenizer.
Adding annotator ssplit
Adding annotator pos
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [2.4 sec].
Adding annotator lemma
Adding annotator ner
Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [6.1 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [4.1 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [3.3 sec].
Initializing JollyDayHoliday for SUTime from classpath: edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1.
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/defs.sutime.txt
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.sutime.txt
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
Adding annotator parse
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... done [4.1 sec].
Adding annotator dcoref
Adding annotator sentiment
> library(rJava)
> .jinit()
[1] 0
> .jcall("java/lang/System","S","getProperty","java.version")
[1] "1.8.0_91"
> 

But if I use RStudio Server on the same machine, with the same user, I get this:

> library(rJava)
> library(coreNLP)
> initCoreNLP()
Error in rJava::.jnew("edu.stanford.nlp.pipeline.StanfordCoreNLP", basename(path)) : 
  java.lang.UnsupportedClassVersionError: edu/stanford/nlp/pipeline/StanfordCoreNLP : Unsupported major.minor version 52.0
> .jinit()
[1] 0
> .jcall("java/lang/System","S","getProperty","java.version")
[1] "1.7.0_67"

In the first place, this didn't work either in the terminal or in RStudio Server. In order to make it work in the terminal I followed these steps:

  1. I downloaded Java from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html, the jdk-8u91-linux-x64.tar.gz file.
  2. Uncompress it in /usr/lib/jvm/jdk1.8.0_91
  3. Finally run sudo JAVA_HOME=/usr/lib/jvm/jdk1.8.0_91 R CMD javareconf

So, I cannot understand why it works in terminal but not in RStudio Server. Seems that RStudio Server cannot load the correct Java, does anyone know why?

Thanks a lot for all your valuable comments.

All the best

Agustin

ACCaminero
  • 33
  • 4

1 Answers1

1

You may want to ask RStudio support. The R script is setting the environment for Java so my guess would be that RStudio server is failing to do that. I don't know how you start it, but you may have more luck by bootstrapping through the R script such as

R CMD <command to start the server>
Simon Urbanek
  • 13,842
  • 45
  • 45