[setup issue] Cannot load java, Jruby-1.7.13, window 7

Hello, I’m a student fairly new at ruby programming, and I’m having a
deal of trouble just to get Jruby running. I was wondering could you
help me figure out how to setup Jruby on window 7?

Here is the supporting information and What I have tried so far:

I followed the instruction at github for Jruby installation, install
Jruby-1.7.13, JDK1.70,
and set the environmental variable to the following:

JAVA_HOME = C:\Program Files\Java\jdk1.7.0_60\bin
JRUBY_HOME = C:\Jruby\jruby-1.7.13\bin
pik 0.2.8

When I tried to test some import java function using SubLime text

To start off small, the test program consist of only a single line of

require ‘java’

I get the following error:

require': cannot load such file -- java (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require’
from C:/RailsInstaller/Ruby Projects/practice notes.rb:257:in `’

Okay, I figure I just need to switch from ruby to Jruby via pik (since
window doesn’t have RVM equivalent)

When I try to add the path of Jruby via Pik using the following

c:\bin>pik add C:\Jruby\jruby-1.7.13\bin

There was an error.
Error: private method `gsub’ called for nil:NilClass

in: pik/commands/command.rb:124:in get_version' in: pik/commands/add_command.rb:23:in add’
in: pik/commands/add_command.rb:13:in `execute’
in: pik_runner:33

I get the above error, the googled solution recommend I try to set the
environmental variable JAVA_HOME and JRUBY_HOME to their corresponding
paths. Which I already did before hand and that doesn’t see to help.

I tried uninstall and reinstall Jruby and Jdk several times, it did not
at all.

Is there a way a way to manually change the Jruby’s load path?

Please bear in mind, I’m a total noob at programming, so I’m not too
familiar with many technical terms. So If it’s possible, please simplify
be as specific as possible in your instruction. Such as specify where to
type what command, or at specify enough terms so I can google them on my

Thank you for your time

On the side notes, does Jruby share all the gems that were donwload by
ruby version? or do I need to duplicate all the gems file in Jruby’s
equivalent library?

View this message in context:
Sent from the JRuby - User mailing list archive at Nabble.com.

Kenny -

It looks like the Ruby 1.9.3 path precedes the JRuby path in your PATH.
As a kludge and a possible way to avoid needing pik, try putting JRuby’s
path first.

Also, I believe you can precede the utility names with ‘j’ for JRuby, so
you can execute ‘jruby’ instead of ‘ruby’, ‘jgem’ instead of ‘gem’,
‘jirb’ instead of ‘irb’.

Another way to execute JRuby code is to use the jruby jar file in a Java
command, something like this:

java -jar jruby.jar my_script.rb

(where jruby.jar will contain the fully qualified filespec of your
installed JRuby jar file, and my_script.rb is the Ruby script you want
to run).

And yes, you will need to gem install any gems you need separately for


Keith R. Bennett


It seems to me that your PATH variable has the wring order.

When you call ‘ruby’ it looks in the folders, specified in this
variable. If it finds a match in a folder before your jruby directory it
just executes this ‘ruby’.

Here it finds MRI(ruby) under the directory
C:\RailsInstaller\Ruby\1.9.3\bin before even reaching the directory

Try to reorder your PATH variable like so:


After setting it you should make a reboot, to apply those changes.

Also, I believe you can precede the utility names with ‘j’ for JRuby, so
you can execute ‘jruby’ instead of ‘ruby’, ‘jgem’ instead of >’gem’,
instead of ‘irb’.

Keith’s suggestion is probably the quickest way to get this running.
try running jruby instead of ruby. You can do jruby -S gem, jruby -S
etc to run any commands that do not have a specific “J” version.

Thanks for the quick responses, as per you guys’ instruction. I did the

Change the order of %PATH% =

run the test program, still cannot load the file path.

Next I did the following and got these responses:

C:> jruby -pry
Error: Could not find or load main class org.jruby.Main

C:> java -jar jruby.jar test.jrb
‘java’ is not recognized as an internal or external command,
operable program or batch file.

C:> java --version
‘java’ is not recognized as an internal or external command,
operable program or batch file.

That’s weird, even though I install Jdk in C:\Program
some how the program is not picking it up

View this message in context:
Sent from the JRuby - User mailing list archive at Nabble.com.

Kenny -

I don’t know how the installation stuff works in JRuby on Windows, but
it looks like:

  1. for the first error, the jruby executable is found, but the jruby.jar
    file is not, and
  2. for the last two errors, the java executable’s directory is not in
    your path.

Have you moved anything around since doing your installations?

I don’t know if the JRuby installation installs its own Java runtime,
but I’d recommend reinstalling Java, reinstalling JRuby, and then

  • Keith

Keith R. Bennett

Java still bin directory also needs to be included in your PATH.

Assuming you quoted your actual configuration, shouldn’t the JAVA_HOME
and JRUBY_HOME variables point to the respective installation root
folder (the
folder above bin, like C:\Program Files\Java\jdk1.7.0_60)?

  • Peter

I tried both the version with bin and without bin. Both fail to run,
re-install several time, still not up and running yet.

The issue might be because I download the JRuby 1.7.13 Windows
Executable+JRE (x64) instead of the version without JRE. Could that be

The weird thing is that even though I have JDK installed, i still
access java

View this message in context:
Sent from the JRuby - User mailing list archive at Nabble.com.