I get an error when I'd like to load rJava. JDK is installed. (I run R on a CentOS VM (cloudera demo vm cdh3u4))
> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/cloudera/R/x86_64-redhat-linux-gnu-library/2.15/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: package/namespace load failed for ‘rJava’
Is there something wrong with LD_LIBRARY_PATH settings? If yes, how can I fix that?
I need rJava running that to install rhdfs later.
Some more information (if needed):
[cloudera#localhost ~]$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
For Ubuntu, oracle-java (7/8) installed. It'll be at this location /usr/lib/jvm and sudo access is required.
Create the file /etc/ld.so.conf.d/java.conf with the following entries:
/usr/lib/jvm/java-8-oracle/jre/lib/amd64
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
(Replace java-8-oracle with java-7-oracle or java-7-openjdk-amd64 depending on your java version)
Then:
sudo ldconfig
Restart RStudio and then install the rJava package.
Getting rJava to work depends heavily on your computers configuration. The following is working at least on a windows platform. You could try and check, if this will help you on your platform, too.
You have to use the same 32bit or 64bit version for both: R and JDK/JRE. A mixture of this will never work (at least for me).
If you use 64bit version make sure, that you do not set JAVA_HOME as a enviorment variable. If this variable is set, rJava will not work for whatever reason. You can check if your JAVA_HOME is set inside R with:
Sys.getenv("JAVA_HOME")
If you need to have JAVA_HOME set (e.g. you need it for maven or something else), you could deactivate it within your R-session with the following code before loading rJava:
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
This should do the trick in most cases. Furthermore this will fix issue Using the rJava package on Win7 64 bit with R, too. I borrowed the idea of unsetting the enviorment variable from R: rJava package install failing.
Related
I want to install an NPM express generator:
sudo apt npm install -g express-generator
It throws the following error:
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home/bin/apt" (-1)
I installed Java in this path (it's not in the System/Library/ - maybe thats the issue?):
'MacintoshSSD/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home'
My .bash_profile looks like that:
export JAVA_HOME=$(/usr/libexec/java_home)
If I check JAVA_HOME it looks fine:
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home
.. and Java version:
java --version
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7)
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
Any idea why it still can find an exectuable?
I an other thread I read about a possible conflict between the pre-installed macOS Java-Version and the Orcalce Java-Version enter link description here but I couldn`t work it out..
And could you explain to me the difference between java_home and JAVA_HOME?
Sorry, I just saw what's wrong...
There used to be an apt tool in Java, but it's gone now. Your mistake is using the linux command line. On many linux systems, another tool called apt is used for installing software.
Check the npm documentation on how to install npm on your Mac, as there are different ways to do it.
Once npm is installed, run sudo npm install -g express-generator (no apt here).
Explanation of the error message
The Java apt-tool was removed in JDK 8. But as JAVA_HOME/bin is normally not on your PATH on Mac, apple provides simple wrappers for all the commands under JAVA_HOME. There still is such a wrapper for apt that tries to run a program with the same name from your Java installation. That's why you get that error message.
conflict between the pre-installed macOS Java-Version and the Orcalce Java-Version:
Apple stopped pre-installing Java in macOS 10.7 so this should not be an issue.
difference between java_home and JAVA_HOME:
JAVA_HOME is an environment variable that points to your Java installation. java_home is a utility program in macOS that makes it easier to correctly set up your JAVA_HOME by listing installed Java versions and the values to use for JAVA_HOME.
I'm using install.packages('rJava', type='source')to install rJava, but it presents with the following error:
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’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
I just installed JDK8 so I'm not sure what's going on.
javac -version throws javac 1.8.0_231
java -version throws java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
This guy at R: rJava package install failing came up with a solution that I don't even understand since I'm new to this, but it has something to do with PATH and JAVA_HOMEand /jre apparently.
Looks like JAVA_HOME points to a JRE, not the JDK you want and need. Have a look at the top voted answer to "What should I set JAVA_HOME to on OS X". Also see https://developer.apple.com/library/archive/qa/qa1170/_index.html
I am trying to install rJava to conduct MaxEnt (Dismo package) on the servers of a super computer that run Linux. All the other packages have been successful, but rJava continues to give errors.
I have followed the answers from this thread including adding jre to my file path, using R CMD javareconf, and installing a new JDK and specifying that as the $JAVA_HOME. Unfortunately, I cannot use the apt-get function because of my role on the servers, although I believe this would be the best solution since it will correct my necessary file paths. However, perhaps I am missing something else that is causing the error.
This is the Java Version I am using:
- openjdk version "1.8.0_181"
- OpenJDK Runtime Environment (build 1.8.0_181-b13)
- OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
This is the error msg that is produced
checking whether ~/Core/java/1.8.0_121/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'
* removing '/home/afila/R/x86_64-pc-linux-gnu-library/3.5/rJava'
The downloaded source packages are in
'/tmp/RtmpvYtNJY/downloaded_packages'
The issue I was having was indeed a permissions problem. Someone helped me resolve it by emulating the root system using proot. After that it was a matter of re-configuring the directory and R's access to it.
In Unix
mkdir ~/etc
cp -a $EBROOTR/lib64/R/etc/* ~/etc
proot -b
R CMD javareconf -e
In R
install.packages("rJava")
library(rJava)
I have made a new Ionic / Cordova project and I'm trying to build it on windows 8.1. I installed JDK and JRE 7 as well as android sdk and ant and added them to my path using the following instructions.
cordova platform add android not working while listing Android targets
When I execute ionic platform add android or cordova I am still getting the following error:
C:\Users\BogdanR\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\q.js:126
throw e;
^
Error: Failed to run 'java -version', make sure your java environment is set up
including JDK and JRE.
Your JAVA_HOME variable is C:\Program Files\Java\jdk1.7.0_51
Error: Command failed: 'java' is not recognized as an internal or external command,
operable program or batch file.
at C:\Users\BogdanR\.cordova\lib\android\cordova\3.4.0\bin\lib\check_reqs.js:62:22
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Socket.<anonymous> (child_process.js:956:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
Error: cmd: Command failed with exit code 8
at ChildProcess.whenDone (C:\nodist\bin\node_modules\cordova\src\superspawn.js:112:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Unable to add platform android. Please see console for more info.
I tried modifying both system variables and user PATH variables.
THE WEIRD THING is that I can type in java -version and it works:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
I am using nodist to manage npm if that is of any relevance.
After I ran into the same issue, the following steps seems to have fixed it:
PATH needs to contain the bin folder of the Java installation path C:\Program Files\Java\jdk1.8.0_05\bin make sure the bin is included
JAVA_HOME needs to be set to the root of that Java installation folder, in my case C:\Program Files\Java\jdk1.8.0_05
In my case, i had multiple java instalations, and whenever i tried to print "echo %java_home%" command on command prompt, it always used to return "%java_home%" as it is.
So i uninstalled all the java versions and then installed it again, and whoola, it worked.
Hope this helps someone.
There is one thing you can try is to set this variable JAVA_HOME to C:\Program Files\Java\jdk1.7.0_51\bin
Since you are using Windows, you can go to Control Panel to update it.
You were able to run java -version probably because it's included in the User's path.
In my case, It said "JAVA_HOME variable is unvalid, C:\Program Files\Java\jdk1.7.0_51".
Then I added a quotation mark to JAVA_HOME. Just like "C:\Program Files\Java\jdk1.7.0_51". Finally It works. May This can be helpful
There was a bad entry in the path that corrupted my whole system path.
C:\Program Files\Microsoft SQL Server\110\Tools\Binn";C:\Program Files\Microsoft\Web Platform Installer\;
Seems like that quotation mark is an entry added by SQL Server installation or web platform. I never added those to the path so it might be the installers fault?
I have been struggling to load the rJava package in R.
I get the following messages
> library(rJava)
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared library \
'C:/PROGRA~1/R/R-210~1.1/library/rJava/libs/rJava.dll':
LoadLibrary failure: The specified module could not be found.
Error : .onLoad failed in 'loadNamespace' for 'rJava'
Error: package/namespace load failed for 'rJava'
I have tried so many solutions that they are all bamboozeled in my head.
At some point I even got
> R Console: Rgui.exe - System Error The
> program can't start because
> MSVCR71.dll is is missing from your
> computer. Try reinstalling the program
> to fix this problem.
I made sure everything I could think of was on the path
> C:\Program Files\R\Rtools\bin;C:\Program Files\R\Rtools\perl\bin;
C:\Program Files\R\Rtools\MinGW\bin;%SystemRoot%\system32;
%SystemRoot%;%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\Program Files\QuickTime\QTSystem\;
C:\Program Files\R\R-2.10.1\library\rJava\libs\;
C:\Program Files\R;C:\Program Files\Java\jre6\bin\client
What should I try next?
I am running R version 2.10.1 (2009-12-14) and I have also tried R version 2.10.1 Patched (2010-03-03 r51210). It is on a Windows machine running windows 7 enterprise
If you have read this threat and neither of the suggestions above has worked so far, then it might be worth trying one further:
Windows 7
R version 2.12.1 (2010-12-16) 64-bit
Java(TM) SE Runtime Environment (build 1.6.0_23-b05), Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
JAVA_HOME=C:\Program Files\Java\jre6\bin\
Path= ...;C:\Program Files\Java\jre6\bin\server\;C:\Program Files\R\R-2.12.1\bin\x64\
The thing that finally solved my problem was to explicitly add \server\ to the PATH variable.
For what it's worth, putting C:\Program Files\Java\jre6\bin\[server] in my PATH worked for me. It seems the rJava module could jot find jvm.dll there.
Here are the versions of R and Java that I'm using (on 64-bit Windows 7).
Java:
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
R:
R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (64-bit)
System information:
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
I encountered this same problem. I was able to solve the issue with one line of code into the command window obtained from this website.
Sys.setenv(JAVA_HOME='C:\Program Files\Java\jre7')
Note that I used this particular line because I was on a 64 bit system. See website for 32-bit example.
Following up on some of Dirk's sage advice:
Your path should probably say C:\Program Files\Java\jre6\bin\ (remove "client").
Your path should also have C:\Program Files\R\R-2.10.1\bin\. You don't need that explicit reference to the rJava libs. I would also then remove C:\Program Files\R from the path.
Lastly, confirm that Java is accessible by either going to your command prompt and typing java -version, or from within R by typing system("java -version").
If you install the SDK, then you will also want a system variable JAVA_HOME which in my case points to C:\Sun\SDK\.
After editing your post for readability / formatting it seems that you have no Java system in your path. I don't use the OS you're trying to use this on, but on mine rJava only works if I also install a Java Run-Time Environment or, better still, a Java SDK.
Note that the package clearly lists
SystemRequirements: java
and that the rJava site clearly states the following
Installation
First, make sure you have
JDK 1.4 or higher installed (some
platforms require hgher version see R
Wiki). On unix systems make sure that
R was configured with Java support. If
not, you can re-configure R by using R
CMD javareconf (you may have to
prepend sudo or run it as root
depending on your installation - see
R-ext manual A.2.2 for details). On
Windows Java is detected at run-time
from the registry.
rJava can be installed as any other R
package from CRAN using
install.packages('rJava'). See the
files section in the left menu for
development versions.
JRI is only compiled if supported,
i.e. if R was configured as a
framework or with --enable-R-shlib.
so I think we have a few smoking guns pointing the same way.
I had a similar error and had to do an additional fix: Setting the R path explicitly to ...bin\x64, and also being consistent in using x64 Java and R.