On the computers (running fedora) at my work R-2.15 is installed by default. I downloaded R-3.0.2 because I need several packages which are only available for R 3.
When i try to call an Rscript from java using Runtime.getRuntime().exec(command); with command being the String Array {"/path/to/Rscript/3-0" "name/of/script" "...args..."} I get the error WARNING: ignoring environment value of R_HOME and it says that it couldn't load the needed packages. When i run the very same command in a terminal it works well.
What is the difference between the call via java and the call on the console. And how can I fix it?
EDIT 1:
when i run my locally installed R-3 version, libPaths returns
> .libPaths()
[1] "/home/<homedir>/.bin/R-3.0.2/library"
But when i call an Rscript from Java, libPaths returns
[1] "/home/<homedir>/R/x86_64-redhat-linux-gnu-library/2.15"
[2] "/usr/lib64/R/library"
[3] "/usr/share/R/library"
[4] "/home/<homedir>/.bin/R-3.0.2/library"
The problem seems to be that Java adds any environment variables that tell R to load packages from the 2.15 installation. How can i prevent this?
EDIT 2:
When i list all environment variables using the System.getenv(); method nothing R-related is shown, the same is the case when i list the environment variables using printenv in the terminal. But when i call Sys.getenv in R the variables R_HOME, R_LIBS, ... are defined. How are these defined?
You can choose the library to look in when you load the package. For example, when calling the script via Rscript, you could use
library(rJava, lib.loc = .libPaths()[4])
Related
I have an application that (I want to) uses Java to start and stop Docker containers. It seems that the way to do this is using docker-machine create, which works fine when I test from the command line.
However, when running using Commons-Exec from Java I get the error:
(aa4567c1-058f-46ae-9e97-56fb8b45211c) Creating SSH key...
Error creating machine: Error in driver during machine creation: /usr/local/bin/VBoxManage modifyvm aa4567c1-058f-46ae-9e97-56fb8b45211c --firmware bios --bioslogofadein off --bioslogofadeout off --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux26_64 --cpus 1 --memory 1024 --acpi on --ioapic on --rtcuseutc on --natdnshostresolver1 off --natdnsproxy1 on --cpuhotplug off --pae on --hpet on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d off --boot1 dvd failed:
VBoxManage: error: Could not find a registered machine with UUID {aa4567c1-058f-46ae-9e97-56fb8b45211c}
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 500 of file VBoxManageModifyVM.cpp
I have set my VBOX_USER_HOME variable in an initializationScript that I'm using to start the machine:
export WORKERID=$1
export VBOX_USER_HOME=/Users/me/Library/VirtualBox
# create the machine
docker-machine create $WORKERID && \ # create the worker using docker-machine
eval $(docker-machine env $WORKERID) && \ # load the env of the newly created machine
docker run -d myimage
And I'm executing this from Java via the Commons Exec CommandLine class:
CommandLine cmdline = new CommandLine("/bin/sh");
cmdline.addArgument(initializeWorkerScript.getAbsolutePath());
cmdline.addArgument("test");
Executor executor = new DefaultExecutor();
If there is another library that can interface with docker-machine from Java I'm happy to use that, or to change out Commons Exec if that's the issue (though I don't understand why). The basic requirement is that I have some way to get docker-machine to create a machine using Java and then later to be able to use docker-machine to stop that machine.
As it turns out the example that I posted should work, the issue that I was having is that I was provisioning machines with a UUID name. That name contained dash (-) characters which apparently break VBoxManage. This might be because of some kind of path problem but I'm just speculating. When I changed my UUID to have dot (.) instead of dash it loaded and started the machine just fine.
I'm happy to remove this post if the moderators want, but will leave it up here in case people are looking for solutions to problems with docker-machine create naming issues.
I took over an old project from an other person. Currently I'm trying to get this project to work.
Already in the beginning I get an Exception in:
R.parseAndEval(".jengine()");
It throws a REngineEvalExcpetion: error during evaluation.
If I use R in the R-Console, I needed to add a parameter .jengine(start=TRUE) to get the command .jengine() working. So I changed this line in Java accordingly, but I still get the same Exception.
I did a tutorial with R without calling .jengine() and using Rengine instead of REngine and at least somehow it worked and I could call R commands within Java.
I'm currently using R 3.3.3 and Java 1.8. I also don't know which versions have been used previously.
"error during evaluation" just means that the R thread that is running the R script failed to run that command. But everything in the Java application is working properly. Is R that is failing.
R has to have the rJava library in order to run .jengine:
library(rJava)
.jinit(".")
.jengine(TRUE)
To run my application from the command line, I run:
java -Dconfig.file=./config/devApp.config -jar ./build/libs/myJar.jar
and inside my code, I have:
String configPath = System.getProperty("config.file");
Which gets the property just fine. However, when I try to debug using the built in debug Netbeans task, the property is null. The output of my run is:
Executing: gradle debug
Arguments: [-Dconfig.file=./config/devApp.config, -PmainClass=com.comp.entrypoints.Runner, -c, /home/me/Documents/projects/proj/settings.gradle]
JVM Arguments: [-Dconfig.file=./config/devApp.config]
Which is coming from:
I set it in both the arguments and JVM arguemtns to see if either would set it. Regardless of what I do, it is null. Can someone help me figure out how to set the system property so my app can get it?
You are setting the property on the Gradle JVM which has almost nothing to do with the JVM your application runs in. If you want to use Gradle to start your app for debugging, you have to tweak your Gradle build file to set or forward the system property to the debug task.
Assuming the debug task is of type JavaExec this would be something like
systemProperty 'config.file', System.properties.'config.file'
in the configuration of your debug task to forward what you set up in the "JVM Arguments" field in Netbeans.
It seems that the "Arguments (each line is an argument):" and "JVM Arguments (each line is an argument):" fields provide values to the Gradle task itself. How I managed to pass properties over to the application was to append them to the jvmLineArgs argument (see image).
My application is now receiving the profiles property.
Thanks to #Vampire for the "guess work", lol!
I met with this error when I used a package in R for loading data, in this package, pakcage rJava was used.
Every time I run a function, the error is
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
This package has been proved without any problem, just some environment problem in my computer.
when I debugged, I found that in the last process before
ls(envir=envir,all.names = private )
the variable envir is NULL,which should be some value but not NULL I think.
After some trials, I kind of solved the problem, by installing rJava every time. And in addition, only when the error comes out, then I install 'rJava', it will work. If I install at the first, it won't work. So, I guess, installing 'rJava'(or probably installing packages), will cause some environment variables to change.
Either Java 7 and Java 8, including jdk or jre are tested, doesn't work. And for R, I am using the 3.1.3 R and all the packages are up to date.
Following is some information that I think may be useful for the troubleshooting.
By installing the package, jvm.dll needs to be added to the windows environment path: "Path" and I did that.
My sessionInfo is shown below:
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.9-1 fields_8.2-1 spam_1.0-1 raster_2.3-33 sp_1.0-17 ecomsUDG.Raccess_2.2-6
[7] downscaleR_0.5-2 maps_2.3-9 downscaleR.java_0.0-2 rJava_0.9-6 gWidgetsRGtk2_0.0-83 cairoDevice_2.22
[13] RGtk2_2.20.31 gWidgets_0.0-54 R.utils_2.0.0 R.oo_1.19.0 R.methodsS3_1.7.0
loaded via a namespace (and not attached):
[1] abind_1.4-3 bitops_1.0-6 boot_1.3-15 CircStats_0.2-4 colorspace_1.2-6 dtw_1.17-1 lattice_0.20-30 MASS_7.3-39
[9] munsell_0.4.2 plyr_1.8.1 proxy_0.4-14 Rcpp_0.11.5 RCurl_1.95-4.5 scales_0.2.4 tools_3.1.3 verification_1.41
Thank you for any help you can provide.
Have u fully solved your issue? i had a similar issue just a few days ago, sorted it out and would like to share with the community. Actually those wrapper functions (in my case, Rbbg package) call rJava functions had a log file in your user folder under C drive, you could delete those log files as it will enable you to escape from the the error message.
In my case, I need to delete the blpjavaapi0.log.0 and org.findata.blpwrapper.0 files created by Rbbg package.
i am trying run the websphere liberty profile server from the command line. I am following the steps told here : https://developer.ibm.com/wasdev/downloads/liberty-profile-using-non-eclipse-environments/
I have created the server with the name server1.
But when the extraction completes and I try to start the server using the command : server start server1
the server throws an error : CWWKE0054E: Unable to open file C:\wlp\wlp\usr\servers\server1\logs\C:\Users\Furquan\AppData\Local\Temp\\ihp_custom_batches.log.. Now I know this cant be a valid path, but I dont know where and how to change it. Please help !!
This error is related to the LOG_FILE environment variable that you have defined in your environment by some other program. To solve that, you have the following opions:
Remove LOG_FILE env variable, if it is no longer needed by your system
If you cant do that, override it via server.env file, that you can create in the wlp\usr\servers\serverName directory with the following content:
LOG_FILE=console.log
As last resort (this is not recommended, will make your installation NOT SUPPORTED and in certain installations might get overwritten by updates) - modify the server.bat command line script - in the script find the following section:
if not defined LOG_FILE (
set X_LOG_FILE=console.log
) else (
set X_LOG_FILE=!LOG_FILE!
)
And after the line set X_LOG_FILE=!LOG_FILE! just add another line that will override it with the default like this set X_LOG_FILE=console.log
In general, I'd recommend second solution (with the server.env file), as it is the most portable and will work in any environment.
I have the similar problem for IBM Support Assistant V5. After I deleted %LOG_FILE% from Environment Variables, it worked.