Cannot get rJava to work properly in MacOS 10.14 - java

I am trying to code using the rSymPy package. When I type in library(rSymPy) I get the following warnings:
> library(rSymPy)
Loading required package: rJython
Loading required package: rJava
Loading required package: rjson
Warning messages:
1: package ‘rJava’ was built under R version 3.4.4
2: package ‘rjson’ was built under R version 3.4.4
This is fine because in theory my code should still work. However, when I try running my function which uses the sympy() command I get the following error:
> moment_generating_function(12)
Show Traceback
Error in .jcheck() : No running JVM detected. Maybe .jinit() would help.
I then run .jinit() which produces no output. Running my code again, I now get the following error
Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), :
java.lang.NullPointerException
I have tried reinstalling my JDK and tried running "r cmd javareconf;" in my terminal multiple times. I would just code this directly in Python but unfortunately my assignment requires I use the rSymPy package in R. I would greatly appreciate any help with this.

Related

JAVA R integration, R package Issues

I have a spring boot application which is calling Rscript using Rcode and while running it on a Windows machine it is working properly, I'm trying to dockerize it.
In my docker container, I'm getting the below error.
java.util.concurrent.ExecutionException: com.github.rcaller.exception.ExecutionException: R command failed with error. Reason: Error: package or namespace load failed for ‘data.table’:
object 'as.xts' not found whilst loading namespace 'data.table'
In addition: Warning message:
package ‘data.table’ was built under R version 3.6.3
Execution halted
Tried multiple options like setting environmental variables, checking R compatibility issue.
I'm new to R, how to make sure all the required R packages are properly installed?
Not finding any workaround.
Your suggestions will be very much appreciated.

Package xlxs installation in R has issues

When trying to install package xlxs in R I get the following error.
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Not sure what to do. I have tried reinstalling Java and still get the same error.
I have R 3.12 on a windows 10 computer.
Any advice is welcome,
Thanks
Error: package or namespace load failed for ‘xlsx’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry!
Try re-installing Java and make sure R and Java have matching
architectures.
The error normally occurs when the architectures(32/64 bit) of java and r does not match.
In order to check the version of java, type java -version in cmd.
You can follow below given steps:
Rstudio > tools > global options > general settings > R-version > change (to the architecture same as that of java) > apply
And you're good to go.

Error while building the demonstration environment for Stucco on MacOS

On following the instructions in http://stucco.github.io/
I am getting the following traceback on terminal:
TASK [smola.java : Install Java packages] **************************************
failed: [stucco] (item=[u'java_packages']) => {"failed": true, "item":
["java_packages"], "msg": "No package matching 'java_packages' is
available"}
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
Any idea on how I can fix this error?
This playbooks are two years old. They use abandoned Ansible syntax. For example here:
- name: Install Java packages
apt: pkg={{ item }} state=latest
with_items: java_packages
You can't use bare variables in with_ with modern Ansible versions (latest version to support this with giant deprecation warning was 2.1).
From Stucco Dev-Setup manual:
Download Ansible. (Tested with version 1.7.x.). (Ansible requires Python 2.6.)

R on Windows 10, rcmdr 'hasjava' error

I am trying to run biodiversity r in r studio with the biodiversity rgui which links up to the rcmdr. I have tried every help forum to find an answer but come up with nothing. I reinstalled R, R studio, updated all packages, installed rjava and javagd and still it refuses to work. I am at wits end!!! I cannot find anything about 'hasjava' and I have updated and installed java already.
Below is copy pasted from the console.
Restarting R session...
> library("BiodiversityR", lib.loc="~/R/win-library/3.2")
Loading required package: tcltk
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.3-0
BiodiversityR 2.5-3: use function 'BiodiversityRGUI()' to launch the BiodiversityR Graphical User Interface
> library("rJava", lib.loc="~/R/win-library/3.2")
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: package or namespace load failed for ‘rJava’
> BiodiversityRGUI()
Sourced: BiodiversityGUI.R
Error : .onAttach failed in attachNamespace() for 'Rcmdr', details:
call: eval(expr, envir, enclos)
error: could not find function "hasJava"
Error: package or namespace load failed for 'Rcmdr'
This problem has nothing directly to do with Windows or with Java.
The Rcmdr package no longer uses Java, and the function hasJava(), which was defined in and exported by the Rcmdr, no longer exists. Apparently BioDiversityR uses this function and needs to be updated appropriately.
You might report your problem directly to the maintainer of BioDiversityR.
I hope this help,
John

Calling Java from Python: "Can't find or load class" Error

I'm trying to call a java program from python using command line. The code is as follows:
subprocess.check_output(["java", "pitt.search.semanticvectors.CompareTerms", "-queryvectorfile","termvectors.bin","term1","term2"])
I get the following error:
Error: Could not find or load main class pitt.search.semanticvectors.CompareTerms
This happens when I run the program from PyDev (version 2.5 in Eclipse 3.7.2). However, if I run the same code from the terminal, it works and I get the result I want.
I'm almost sure that the problem is related with some configuration of PyDev and how it handles the java CLASSPATH, which is:
/Users/feralvam/Programas/semanticvectors-3.4/semanticvectors-3.4.jar:/Users/feralvam/Programas/lucene-3.5.0/lucene-core-3.5.0.jar:/Users/feralvam/Programas/lucene-3.5.0/contrib/demo/lucene-demo-3.5.0.jar:
The class "pitt.search.semanticvectors.CompareTerms" is in "semanticvectors-3.4.jar".
Any help you could give me would be really appreciated.
Thanks!
The solution proposed by #eis worked. Now, the command is:
subprocess.check_output(["java", "-classpath", "/Users/feralvam/Programas/semanticvectors-3.4/semanticvectors-3.4.jar:/Users/feralvam/Programas/lucene-3.5.0/lucene-core-3.5.0.jar:/Users/feralvam/Programas/lucene-3.5.0/contrib/demo/lucene-demo-3.5.0.jar:", "pitt.search.semanticvectors.CompareTerms", "-queryvectorfile","/Users/feralvam/termvectors.bin","term1","term2"])

Categories

Resources