"No Java runtime" error in OS X 10.10 using Oracle's 1.8.0 JVM #37

Closed
serpico7456 opened this Issue Dec 5, 2014 · 28 comments

Comments

Projects
None yet
10 participants
@serpico7456

I've tried 3 different Macs running OS X 10.10, R 3.1.2, Java 1.8.0_25, and rJava 0.9-7. In all three cases rJava installs from source without error but after running .jinit(), fails to detect Java and prompts to install Java 6 from apple. Another researcher at my institution reports the same issue.

I've spent hours researching online, but haven't yet found a solution and tried various things like manually setting JAVA_HOME and LD_LIBRARY_PATH to no avail.

R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_25
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
...

~ % echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
~ % echo $LD_LIBRARY_PATH
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/server

~ % R CMD INSTALL rJava_0.9-7.tar.gz

full compile output

~ % R

library('rJava')
.jinit()
No Java runtime present, requesting install.

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Dec 10, 2014

Owner

I suspect this is something for Oracle support/lists, because rJava loads the correct JVM, but Oracle's code attempts to fall back to Apple Java or something like that:

> library(rJava)
dyld: loaded: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rJava/libs/rJava.so
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/server/libjvm.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib
> .jinit()
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/libverify.dylib
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/libjava.dylib
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/libzip.dylib
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
dyld: loaded: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
dyld: loaded: /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
No Java runtime present, requesting install.

FWIW my javareconf is finding the full JDK correctly without any overrides:

$ R CMD javareconf -n
Java interpreter : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java
Java version     : 1.8.0_20
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java compiler    : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/jar
Non-system Java on OS X

trying to compile and link a JNI progam 
detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Owner

s-u commented Dec 10, 2014

I suspect this is something for Oracle support/lists, because rJava loads the correct JVM, but Oracle's code attempts to fall back to Apple Java or something like that:

> library(rJava)
dyld: loaded: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rJava/libs/rJava.so
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/server/libjvm.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib
> .jinit()
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/libverify.dylib
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/libjava.dylib
dyld: loaded: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/libzip.dylib
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
dyld: loaded: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
dyld: loaded: /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
No Java runtime present, requesting install.

FWIW my javareconf is finding the full JDK correctly without any overrides:

$ R CMD javareconf -n
Java interpreter : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java
Java version     : 1.8.0_20
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java compiler    : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/jar
Non-system Java on OS X

trying to compile and link a JNI progam 
detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm

@s-u s-u changed the title from Installed from source, can't detect java to "No Java runtime" error in OS X 10.10 using Oracle's 1.8.0 JVM Dec 10, 2014

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Dec 18, 2014

Owner

Ok, this is officially a Java 1.8 bug:

https://bugs.openjdk.java.net/browse/JDK-7131356

Ironically, you have to install 1.6 from Apple

http://support.apple.com/kb/DL1572

then Oracle Java 1.8 will start working.

Owner

s-u commented Dec 18, 2014

Ok, this is officially a Java 1.8 bug:

https://bugs.openjdk.java.net/browse/JDK-7131356

Ironically, you have to install 1.6 from Apple

http://support.apple.com/kb/DL1572

then Oracle Java 1.8 will start working.

@sdaza

This comment has been minimized.

Show comment
Hide comment
@sdaza

sdaza Dec 18, 2014

But R still will use Java 6:

 library(rJava)  
 .jinit()
 .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
 [1] "1.6.0_65-b14-466.1-11M4716"

I need R uses Java 8 in order to use RNetLogo :(

sdaza commented Dec 18, 2014

But R still will use Java 6:

 library(rJava)  
 .jinit()
 .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
 [1] "1.6.0_65-b14-466.1-11M4716"

I need R uses Java 8 in order to use RNetLogo :(

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Dec 18, 2014

Owner

Nope, if you link it against 1.8:

> library(rJava)
> .jinit()
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_20-b26"

This is with the config above.

1.8 needs the presence of 1.6, it will still correctly load the 1.8 JVM but due to the bug described above it makes a call to the system that will trip the 1.6 detection so the 1.8 JNI only works if 1.6 is installed.

Owner

s-u commented Dec 18, 2014

Nope, if you link it against 1.8:

> library(rJava)
> .jinit()
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_20-b26"

This is with the config above.

1.8 needs the presence of 1.6, it will still correctly load the 1.8 JVM but due to the bug described above it makes a call to the system that will trip the 1.6 detection so the 1.8 JNI only works if 1.6 is installed.

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Dec 18, 2014

Owner

If in doubt, check with DYLD_PRINT_LIBRARIES=1 (that's what the above output shows) to make sure you have linked rJava against 1.8 and not 1.6. If you have the wrong one either re-configure R (like I did above) or for a quick fix use install_name_tool on rJava.so to pick whichever libjvm you need.

Owner

s-u commented Dec 18, 2014

If in doubt, check with DYLD_PRINT_LIBRARIES=1 (that's what the above output shows) to make sure you have linked rJava against 1.8 and not 1.6. If you have the wrong one either re-configure R (like I did above) or for a quick fix use install_name_tool on rJava.so to pick whichever libjvm you need.

@conjugateprior

This comment has been minimized.

Show comment
Hide comment
@conjugateprior

conjugateprior Dec 18, 2014

Hmm. Installed Oracle Java 1.8 (it works). Installed Java 1.6 from Apple (it gets picked up by rJava). Recofingured R via sudo R CMD javareconf -n (gives a lot of information about how it's using 1.8).

But then

library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.6.0_65-b14-466.1-11M4716"

So I guess reconfiguration is not working.

Hmm. Installed Oracle Java 1.8 (it works). Installed Java 1.6 from Apple (it gets picked up by rJava). Recofingured R via sudo R CMD javareconf -n (gives a lot of information about how it's using 1.8).

But then

library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.6.0_65-b14-466.1-11M4716"

So I guess reconfiguration is not working.

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Dec 18, 2014

Owner

Like I said, check which one you linked against (otool -L) and which libjvm you're loading.

Owner

s-u commented Dec 18, 2014

Like I said, check which one you linked against (otool -L) and which libjvm you're loading.

@sdaza

This comment has been minimized.

Show comment
Hide comment
@sdaza

sdaza Dec 18, 2014

Great! Now it is working on my laptop :)

sdaza commented Dec 18, 2014

Great! Now it is working on my laptop :)

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Dec 18, 2014

Owner

@conjugateprior to clarify - after re-configuring R you still have to re-compile rJava to pick up the new R settings

Owner

s-u commented Dec 18, 2014

@conjugateprior to clarify - after re-configuring R you still have to re-compile rJava to pick up the new R settings

@conjugateprior

This comment has been minimized.

Show comment
Hide comment
@conjugateprior

conjugateprior Dec 18, 2014

Aha. I'd already re-installed as binary, but install.packages('rJava', type='source') seems to have done the trick.

.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_05-b13"

Aha. I'd already re-installed as binary, but install.packages('rJava', type='source') seems to have done the trick.

.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_05-b13"
@yufree

This comment has been minimized.

Show comment
Hide comment
@yufree

yufree Jan 4, 2015

Hi, I tried @conjugateprior 's method(re-config R and rJava) and it still show me 1.6.0_65-b14-466.1-11M4716. When I use JGR, the issue disappeared. I am still confused but right now I could use RNetLogo.

yufree commented Jan 4, 2015

Hi, I tried @conjugateprior 's method(re-config R and rJava) and it still show me 1.6.0_65-b14-466.1-11M4716. When I use JGR, the issue disappeared. I am still confused but right now I could use RNetLogo.

@conjugateprior

This comment has been minimized.

Show comment
Hide comment
@conjugateprior

conjugateprior Jan 4, 2015

@yufree I've put as much as I understand in a blog post. The comments also have some detail on setting paths. I suppose it's possible that JGR is setting them correctly for you when loaded. (I've never used it, so I don't know.)

@yufree I've put as much as I understand in a blog post. The comments also have some detail on setting paths. I suppose it's possible that JGR is setting them correctly for you when loaded. (I've never used it, so I don't know.)

@yufree

This comment has been minimized.

Show comment
Hide comment
@yufree

yufree Jan 4, 2015

Thank you! I checked you posts and tried again in RStudio, still 1.6, not 1.8. It seemed something wired happened between RStudio and rJava.

yufree commented Jan 4, 2015

Thank you! I checked you posts and tried again in RStudio, still 1.6, not 1.8. It seemed something wired happened between RStudio and rJava.

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Jan 4, 2015

Owner

Note that there is a very nasty bug in Yosemite concerning environment variables, so you may want to avoid RStudio for installing packages - use R in the shell which doesn't trigger the bug. First try if things are working in command line R, if they do then worry about RStudio (check for updates/betas since I know they have been working around that bug in some version).

To check what's happening, you can set DYLD_PRINT_LIBRARIES and it will show you which libjvm is loaded - you want the one from Java 1.8.

Owner

s-u commented Jan 4, 2015

Note that there is a very nasty bug in Yosemite concerning environment variables, so you may want to avoid RStudio for installing packages - use R in the shell which doesn't trigger the bug. First try if things are working in command line R, if they do then worry about RStudio (check for updates/betas since I know they have been working around that bug in some version).

To check what's happening, you can set DYLD_PRINT_LIBRARIES and it will show you which libjvm is loaded - you want the one from Java 1.8.

@yufree

This comment has been minimized.

Show comment
Hide comment
@yufree

yufree Jan 4, 2015

Thanks @s-u .In fact I know the bug and I always run RStudio from terminal and it could solve most of the problems because RStudio could inherit the environment variables from treminal. But this one it didn't work.

/Applications/RStudio.app/Contents/MacOS/RStudio

For DYLD_PRINT_LIBRARIES, I found the rJava still use 1.6.

> library(rJava)
dyld: loaded: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rJava/libs/rJava.so
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
dyld: loaded: /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
> .jinit()
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bundle/Libraries/libclient64.dylib
dyld: loaded:     /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/../Libraries/libjvmlinkage.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libverify.dylib
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation
dyld: loaded: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjava.jnilib
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaRuntimeSupport.framework/Versions/A/JavaRuntimeSupport
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libzip.jnilib

I tried to use sudo R CMD javareconf -n, it seemed R has known 1.8.

Java interpreter : /usr/bin/java
Java version     : 1.8.0_20
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on OS X

trying to compile and link a JNI progam 
detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm

Then I try to install rJava from source install.packages('rJava', type='source'). Try the following code

library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

Still 1.6.0_65-b14-466.1-11M4716. I think I have re-config R and rJava but rJava just ignore 1.8. I also confused by JGR, same code and the output is 1.8.0_20-b26. This is the right one.

Thus, I think rJava and JGR are fine but connection between RStudio and rJava has something wrong. I hope this issue only happened in my mac.

yufree commented Jan 4, 2015

Thanks @s-u .In fact I know the bug and I always run RStudio from terminal and it could solve most of the problems because RStudio could inherit the environment variables from treminal. But this one it didn't work.

/Applications/RStudio.app/Contents/MacOS/RStudio

For DYLD_PRINT_LIBRARIES, I found the rJava still use 1.6.

> library(rJava)
dyld: loaded: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rJava/libs/rJava.so
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
dyld: loaded: /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
> .jinit()
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bundle/Libraries/libclient64.dylib
dyld: loaded:     /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/../Libraries/libjvmlinkage.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libverify.dylib
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation
dyld: loaded: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjava.jnilib
dyld: loaded: /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaRuntimeSupport.framework/Versions/A/JavaRuntimeSupport
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
dyld: loaded: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libzip.jnilib

I tried to use sudo R CMD javareconf -n, it seemed R has known 1.8.

Java interpreter : /usr/bin/java
Java version     : 1.8.0_20
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on OS X

trying to compile and link a JNI progam 
detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm

Then I try to install rJava from source install.packages('rJava', type='source'). Try the following code

library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

Still 1.6.0_65-b14-466.1-11M4716. I think I have re-config R and rJava but rJava just ignore 1.8. I also confused by JGR, same code and the output is 1.8.0_20-b26. This is the right one.

Thus, I think rJava and JGR are fine but connection between RStudio and rJava has something wrong. I hope this issue only happened in my mac.

@sherbrich

This comment has been minimized.

Show comment
Hide comment
@sherbrich

sherbrich Jan 12, 2015

@sdaza - could you provide a walk through (with terminal commands) of what you did to finally get this working on your laptop?

@sdaza - could you provide a walk through (with terminal commands) of what you did to finally get this working on your laptop?

@sdaza

This comment has been minimized.

Show comment
Hide comment
@sdaza

sdaza Jun 16, 2015

@sherbrich This is what I did (remember that I use R in terminal):

  1. Install Java 8 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
  2. Install Java 6 from Mac (http://support.apple.com/kb/DL1572)
  3. It is necessary to define correctly the java home directory. I used /Library/Java/Home, but it could be another one. You can use an eclipse IDE (preferences, installed jREs) to set the right directory.
  4. Reconfigure R using sudo R CMD javareconf -n in terminal
  5. Install rJava as source install.packages("rJava", type="source")
  6. You can check in the terminal to make sure you have linked rJava against 1.8 and not 1.6.
DYLD_PRINT_LIBRARIES=1 R 
library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

Then, install RNetLogo. That's it.

sdaza commented Jun 16, 2015

@sherbrich This is what I did (remember that I use R in terminal):

  1. Install Java 8 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
  2. Install Java 6 from Mac (http://support.apple.com/kb/DL1572)
  3. It is necessary to define correctly the java home directory. I used /Library/Java/Home, but it could be another one. You can use an eclipse IDE (preferences, installed jREs) to set the right directory.
  4. Reconfigure R using sudo R CMD javareconf -n in terminal
  5. Install rJava as source install.packages("rJava", type="source")
  6. You can check in the terminal to make sure you have linked rJava against 1.8 and not 1.6.
DYLD_PRINT_LIBRARIES=1 R 
library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

Then, install RNetLogo. That's it.

@hdbeukel

This comment has been minimized.

Show comment
Hide comment
@hdbeukel

hdbeukel Aug 10, 2015

I am experiencing this issue as well and tried all your suggestions, without success. Both Java 8 and 6 are installed, I defined the necessary environment variables, reconfigured R and reinstalled rJava from source. Still, R links rJava against 1.6 instead of 1.8.

Is there anything else I can try?

I am experiencing this issue as well and tried all your suggestions, without success. Both Java 8 and 6 are installed, I defined the necessary environment variables, reconfigured R and reinstalled rJava from source. Still, R links rJava against 1.6 instead of 1.8.

Is there anything else I can try?

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Aug 12, 2015

Owner

An update on the Oracle bug: it will be fatal eventually, because Apple will stop providing 1.6 runtime at which point you can't get 1.6 to appease the Oracle loader so you can't load 1.8.

But thanks to Mike Swingler at Apple we have a work-around (the stub checks for the existence of libjli to see if it should try 1.6). In fact we may end up using a way to detect JVM at run-time just like we do on Windows since that's probably the only way to support Oracle Java in the long run given its non-standard location that changes with each update.

If you want to try the work-around, run the following:

library(rJava)
dyn.load("/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/jli/libjli.dylib", FALSE)
.jinit()

(replace the jli location with the corresponding one for your JVM)

Owner

s-u commented Aug 12, 2015

An update on the Oracle bug: it will be fatal eventually, because Apple will stop providing 1.6 runtime at which point you can't get 1.6 to appease the Oracle loader so you can't load 1.8.

But thanks to Mike Swingler at Apple we have a work-around (the stub checks for the existence of libjli to see if it should try 1.6). In fact we may end up using a way to detect JVM at run-time just like we do on Windows since that's probably the only way to support Oracle Java in the long run given its non-standard location that changes with each update.

If you want to try the work-around, run the following:

library(rJava)
dyn.load("/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/jli/libjli.dylib", FALSE)
.jinit()

(replace the jli location with the corresponding one for your JVM)

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Aug 12, 2015

Owner

For those that have trouble forcing 1.8, try the following:

jvm=`ls /Library/Java/JavaVirtualMachines/*/Contents/Home/jre/lib/server/libjvm.dylib`
sudo install_name_tool -id "$jvm" "$jvm"

and then re-compile rJava from sources. That above makes sure that jvm will link in the proper full path to the library so it's guaranteed to be found - even if no special environment variables are set. (Note: it assumes you have only one JVM in that directory - if you have multiple, set jvm to whichever you want to use).

Owner

s-u commented Aug 12, 2015

For those that have trouble forcing 1.8, try the following:

jvm=`ls /Library/Java/JavaVirtualMachines/*/Contents/Home/jre/lib/server/libjvm.dylib`
sudo install_name_tool -id "$jvm" "$jvm"

and then re-compile rJava from sources. That above makes sure that jvm will link in the proper full path to the library so it's guaranteed to be found - even if no special environment variables are set. (Note: it assumes you have only one JVM in that directory - if you have multiple, set jvm to whichever you want to use).

@hdbeukel

This comment has been minimized.

Show comment
Hide comment
@hdbeukel

hdbeukel Aug 13, 2015

The trick with setting

jvm=`ls /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/server/libjvm.dylib`
sudo install_name_tool -id "$jvm" "$jvm"

before installing rJava from source worked for me. Thanks!

The trick with setting

jvm=`ls /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/server/libjvm.dylib`
sudo install_name_tool -id "$jvm" "$jvm"

before installing rJava from source worked for me. Thanks!

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Sep 2, 2015

Owner

If you have any of these issues, please try rJava 0.9-8, it tries to address most issues involved - the stub bug as well as the fact that Oracle Java doesn't contain paths and OS X strips DYLD_FALLBACK_LIBRARY_PATH when passing from R to the build script.

Owner

s-u commented Sep 2, 2015

If you have any of these issues, please try rJava 0.9-8, it tries to address most issues involved - the stub bug as well as the fact that Oracle Java doesn't contain paths and OS X strips DYLD_FALLBACK_LIBRARY_PATH when passing from R to the build script.

@rodrigomurta

This comment has been minimized.

Show comment
Hide comment
@rodrigomurta

rodrigomurta Oct 4, 2015

I still have problem to make rJava recognise Java 8 in OSX 10.11. I tried to install version 0.9-8, but I get:
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
I tried this SE post rJava package install failing, without success.

I still have problem to make rJava recognise Java 8 in OSX 10.11. I tried to install version 0.9-8, but I get:
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
I tried this SE post rJava package install failing, without success.

@kingo55

This comment has been minimized.

Show comment
Hide comment
@kingo55

kingo55 Nov 2, 2015

@rodrigomurta - I've tried this too. Looks to be another Java issue with rebuilding.

Can we compile R packages outside of R? Have no troubles accessing 1.8.0 outside of R....

kingo55 commented Nov 2, 2015

@rodrigomurta - I've tried this too. Looks to be another Java issue with rebuilding.

Can we compile R packages outside of R? Have no troubles accessing 1.8.0 outside of R....

@jirutka

This comment has been minimized.

Show comment
Hide comment
@jirutka

jirutka Nov 15, 2015

I wrote an user friendly script for this hack with relinking rJava.so against specific Java VM: https://gist.github.com/jirutka/ab8ccaf40e10773cb17f

jirutka commented Nov 15, 2015

I wrote an user friendly script for this hack with relinking rJava.so against specific Java VM: https://gist.github.com/jirutka/ab8ccaf40e10773cb17f

@s-u

This comment has been minimized.

Show comment
Hide comment
@s-u

s-u Nov 16, 2015

Owner

Please don't use any "hacks" like the above (@jirutka) - they are pointless with Java 1.8, because the linked path is ignored anyway. As mentioned above, please use rJava 0.9-8 which works around the issues both in Oracle Java and in most recent OS X versions.

Owner

s-u commented Nov 16, 2015

Please don't use any "hacks" like the above (@jirutka) - they are pointless with Java 1.8, because the linked path is ignored anyway. As mentioned above, please use rJava 0.9-8 which works around the issues both in Oracle Java and in most recent OS X versions.

@jirutka

This comment has been minimized.

Show comment
Hide comment
@jirutka

jirutka Nov 16, 2015

rJava version has been bumped to 0.9-8 ~2 months ago in this repo, so why the heck it's still not on CRAN (there's 0.9-7)?! Well, it's my fault that I didn't double check the installed version, but still...

jirutka commented Nov 16, 2015

rJava version has been bumped to 0.9-8 ~2 months ago in this repo, so why the heck it's still not on CRAN (there's 0.9-7)?! Well, it's my fault that I didn't double check the installed version, but still...

@jirutka

This comment has been minimized.

Show comment
Hide comment
@jirutka

jirutka Nov 16, 2015

I disagree that it's pointless, it obviously isn't since it solved the problem for me and friend of mine. It's nasty hack, but the only way that actually worked.

jirutka commented Nov 16, 2015

I disagree that it's pointless, it obviously isn't since it solved the problem for me and friend of mine. It's nasty hack, but the only way that actually worked.

@s-u s-u closed this Jan 29, 2016

@tobiasherzke tobiasherzke referenced this issue in Homebrew/homebrew-science Nov 25, 2016

Closed

Java support for Octave without Apple's Legacy Java 6 #4643

4 of 5 tasks complete

@amanpsbhatia amanpsbhatia referenced this issue in ryanphuang/liballuxio Nov 28, 2016

Closed

Problem while running on OSX #4

@TingluoHuang TingluoHuang referenced this issue in Microsoft/vsts-agent May 24, 2017

Open

Specified which Java installation to use #989

@apjanke apjanke referenced this issue in octave-app/octave-app-bundler Jun 21, 2018

Closed

Test suite crashes #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment