0
votes

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

3

3 Answers

0
votes

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.

0
votes

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).

-1
votes

To get JRuby on your system, install the most recent JRuby binary file for your system, extract it, and then work with it from the command line in a terminal window or command window