Trying to install rJava but error says JDK is incomplete - java

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

Related

rJava fails to install on server

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)

Running Netbeans for Java

I have a problem with running Netbeans for Java development..
When I try to run it I get
I checked the config located in <netbeans_dir>/etc/netbeans.conf and found following setting:
netbeans_jdkhome="/usr/"
So, I checked java and javac:
>>java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
>>whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz
>>javac -version
javac 1.8.0_151
>>whereis javac
javac: /usr/bin/javac /usr/share/man/man1/javac.1.gz
So I updated netbeans_jdkhome to /usr/bin/javac. Now, when I try to run Netbeans I get
Cannot find java. Please use the --jdkhome switch.
I also tried to reinstall Java according to this instruction but once I did and changed jdkhome to /usr/lib/jvm/java-8-openjdk I still get Cannot find java.
What should I enter to run Netbeans properly?
Tools -> Java Platforms -> Add platform should display something like this:
Notice that Platform folder has small rectangle that indicates it can be chosen.

java/lang/NoClassDefFoundError: java/lang/invoke/MethodHandle eclipse juno

Im running Eclipse Juno on Mac OSX 10.8.4, I tried to update my jdk to 1.7 when I run my Java App and I have this error:
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/invoke/MethodHandle
if I run on terminal
java -version
I get this
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
for updating this I set on Eclipse
Window - Preferences - Java - Installed JREs - Duplicate
JRE home: /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
JRE name: Java SE 7 (MacOS X Default)
also changed compiler level
Window - Preferences - Java - Compiler - Compiler compilance level: 1.7
also added next lines to /Users/myUser/.bash_profile:
VA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
export JAVA_HOME=$VA_HOME
export CLASSPATH=$VA_HOME
export PATH=$PATH:$JAVA_HOME/bin
but still getting same error
Any help I'll appreciate
in your launch configuration, check that the right JRE System Library is on the Classpath
Have you added JAVA_HOME to your PATH? Usually you get this problem due to a bad installation of the SDK. Try
javac -version
From the command line and see if this differs to
java -version
And produces the same NoClassDefFoundError as above.
The most probable reason of java/lang/NoClassDefFoundError is that you have a jar in your classpath which references another jar which is missing in classpath. The referencing classes won't be initialized.
Now for your case, you upgraded to 1.7 which would have added dependencies. Make sure your classpath now refers to jdk/jre 1.7

Sencha Cmd installation on Mac: Java not found

Trying to install Sencha Command 3.1.1 on my iMac (10.8.3). The installer is saying:
The installer could not find a valid Java(tm) on this machine.
Supported versions: Vendor : Any min. 1.6.0 max. any
Following another Stack Overflow thread, I tried linking /usr/bin/java to /Library/Internet Plugins/JavaAppletPlugin.plugin/Contents/Home/bin/java. Now, I get this on the command line:
~ 🍔 java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
So that looks good, but the installer still complains that it cannot find Java. Why can't it?
What eventually fixed this for me, after consulting with Sencha support, was installing the full JDK rather than just the JRE. I don't know exactly why this fixed it, or what the root cause was, but now Command installed successfully and is working fine.
I had JDK installed, but one thing worked for me was exporting $java_home/bin:
export PATH=$JAVA_HOME/bin:$PATH

Error while loading rJava

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.

Categories

Resources