I need to install java gem for my jruby package. The below is the error it gives me.
C:\\Users\\abcd>jruby -v
jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on Java HotSpot(TM) 64-Bit Server VM 1.8.0_31-b13 +jit [Windows 7-amd64]
C:\\Users\\abcd>jgem install java
io/console not supported; tty will not be manipulated ERROR: Error installing java: java requires Ruby version >= 2.1.0.
From irb console when I say require 'java' this gives me 'false' always
If you look at https://github.com/vanruby/java/blob/master/java.gemspec you'll see ruby version must be >= 2.1.0
This is the same as the error you got.
jruby 1.7.19 has only 2 modes: 1.8 and 1.9 modes.
If you want ruby modes >= 2.x, you need to move to jruby-9k, not yet released but a pre-2 version is available for tests:
http://jruby.org/2015/04/28/jruby-9-0-0-0-pre2.html
jruby 9k pre2 has ruby mode 2.2.2 and the installation will work nicely:
jruby -v
jruby 9.0.0.0.pre2 (2.2.2) 2015-04-28 2755ae0 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [Windows 7-amd64]
jgem ins -l java-0.0.2.gem
Successfully installed java-0.0.2 1 gem installed
Please note in my case I downloaded the gem locally, as I've some internal network restrictions.
the java gem is a "joke" around Java ... JRuby on the other hand provides you "serious" access to the full underlying Java APIs and actually internally already has a require 'java'
(it's always loaded by default since JRuby 1.7.x thus $LOADED_FEATURES
will always have java loaded).
although this might sound like not an answer - do not use gem 'java'
under JRuby it's author probably never tried JRuby and did not realize it will collide and give users a hard time (in general it's best to avoid Ruby-ists joking around Java since they occasionally produce non thread-safe code).
要在系统上使用JRuby,请为系统安装最新的JRuby二进制文件,将其解压缩,然后从终端窗口或命令窗口中的命令行使用它
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.