arton / rjb

Ruby Java Bridge
https://www.artonx.org/collabo/backyard/?RubyJavaBridge
GNU Lesser General Public License v2.1
117 stars 34 forks source link

No Java runtime present, requesting install. #56

Closed maxime-carbonneau closed 7 years ago

maxime-carbonneau commented 7 years ago

On MacOS X Sierra, with jdk1.8.0_121 install, Rjb::import('anything') will halt the process with the message : No Java runtime present, requesting install. I had to install Java6 from Apple (https://support.apple.com/kb/DL1572) to fix the issue. Why?

arton commented 7 years ago

Short answer => you didn't install Java with OSX standard. If Java was installed by the correct way, /usr/libexec/java_home shows the right path to Java. Of course Rjb obeys Apple standard.

maxime-carbonneau commented 7 years ago

According to your answer, I didn't express myself correctly. /usr/libexec/java_home was showing /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home has expected. But, Rjb::import('anything') didn't work until I install Java6. And now, /usr/libexec/java_home still show /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home

arton commented 7 years ago

What files in the directory? Are there valid Java system? Or you may set JAVA_HOME environmental variable. Rjb checks the variable prior reading /usr/libexec/java_home for overriding testing Java environment.

maxime-carbonneau commented 7 years ago

I try with and without JAVA_HOME. JAVA_HOME was set in my .bash_profile like this : export JAVA_HOME=$(/usr/libexec/java_home) jdk1.8.0_121 was installed with the installer downloaded from Oracle (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) I pretty sure I did it the "correct" way

arton commented 7 years ago

Why do you think it as correct way of Apple? I think it's correct way of Oracle.

arton commented 7 years ago

Umm, I also use Orcale Java.

irb(main):001:0> require 'rjb' => true irb(main):002:0> sys = Rjb::import('java.lang.System') => #<Rjb::Java_lang_System:0x007ffae88af3c8 @user_initialize=nil> irb(main):003:0> sys.property('java.version').to_s => "1.8.0_20" irb(main):004:0> sys.property('java.vendor').to_s => "Oracle Corporation"

They changed their way between 1.8.0.20 and 1.3.0.121

maxime-carbonneau commented 7 years ago

I use the word "correct" because you wrote

If Java was installed by the correct way

maxime-carbonneau commented 7 years ago

I just don't understand why do I need to install Java6 to use your gem. With Java6 (from Apple) and Java8 (from Oracle) on my system, I get the following output

2.3.1 :001 > require 'rjb' => true 2.3.1 :002 > sys = Rjb::import('java.lang.System') => #<Rjb::Java_lang_System:0x007fc06b9f28a0 @user_initialize=nil> 2.3.1 :003 > sys.property('java.version').to_s => "1.8.0_121" 2.3.1 :004 > sys.property('java.vendor').to_s => "Oracle Corporation"

arton commented 7 years ago

I remembered the case likes yours.

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

Installing JDK6 is correct workaround I think.

twelve17 commented 6 years ago

I ran into this problem too, and this fixed it for me: https://github.com/arton/rjb/issues/30#issuecomment-66909871

My version info:

java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
aroop commented 4 years ago

I had the same issue and was able to fix this.

Environment: macOs Catalina

Root cause: By default JDK from oracle only enabled the CommandLine capability but this library needed JNI and possibly more capabilities because of which macOs was suggesting me to install the old version of the Java from Apple which had those capabilities enabled by default.

Fix: I fixed this issue by adding the following entires to /Library/Java/JavaVirtualMachines/jdk<???>/Contents/info.plist file under JVMCapabilities array

I tested this with both java both java 8 and 13