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

**URL:** <https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613>\
**Category:** JRuby\
**Created:** [June 26, 2014, 4:47am UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613 "2014-06-26T04:47:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [June 26, 2014, 4:47am UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/1 "2014-06-26T04:47:47Z")

</div>

Hello, I’m a student fairly new at ruby programming, and I’m having a  
huge  
deal of trouble just to get Jruby running. I was wondering could you  
gusy  
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  
PATH =  
C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby1.9.3\bin;C:\Jruby\jruby-1.7.13\bin  
pik 0.2.8

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

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

require ‘java’

I get the following error:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/site\_ruby/1.9.1/rubygems/custom\_require.rb:36:in  
`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  
commands:

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  
help  
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  
and  
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  
own.

Thank you for your time

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

–  
View this message in context:  
[http://ruby.11.x6.nabble.com/setup-issue-Cannot-load-java-Jruby-1-7-13-window-7-tp5000589.html](http://ruby.11.x6.nabble.com/setup-issue-Cannot-load-java-Jruby-1-7-13-window-7-tp5000589.html)  
Sent from the JRuby - User mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [June 26, 2014, 5:12am UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/2 "2014-06-26T05:12:48Z")

</div>

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

Cheers,  
Keith

Keith R. Bennett

> **[Keith R. Bennett on about.me](https://about.me/keithrbennett)**
>
> I am a software engineer in Reston, Virginia. Visit my website.

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [June 26, 2014, 5:21am UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/3 "2014-06-26T05:21:08Z")

</div>

Hello,

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  
C:\Jruby\jruby-1.7.13\bin

Try to reorder your PATH variable like so:

PATH=C:\RailsInstaller\Git\cmd;C:\Jruby\jruby-1.7.13\bin;C:\RailsInstaller\Ruby1.9.3\bin

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

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [June 26, 2014, 5:44am UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/4 "2014-06-26T05:44:54Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [June 27, 2014, 1:20pm UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/5 "2014-06-27T13:20:51Z")

</div>

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

Change the order of %PATH% =  
C:\RailsInstaller\Git\cmd;C:\Jruby\jruby-1.7.13\bin;C:\RailsInstaller\Ruby1.9.3\bin

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  
Files\Java\jdk1.7.0\_60  
some how the program is not picking it up

–  
View this message in context:  
[http://ruby.11.x6.nabble.com/setup-issue-Cannot-load-java-Jruby-1-7-13-window-7-tp5000589p5000616.html](http://ruby.11.x6.nabble.com/setup-issue-Cannot-load-java-Jruby-1-7-13-window-7-tp5000589p5000616.html)  
Sent from the JRuby - User mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [June 27, 2014, 3:06pm UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/6 "2014-06-27T15:06:41Z")

</div>

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

- Keith

Keith R. Bennett

> **[Keith R. Bennett on about.me](https://about.me/keithrbennett)**
>
> I am a software engineer in Reston, Virginia. Visit my website.

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [June 27, 2014, 3:18pm UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/7 "2014-06-27T15:18:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [June 30, 2014, 8:34am UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/8 "2014-06-30T08:34:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KennyHuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@KennyHuang](https://www.ruby-forum.com/u/KennyHuang)\
**Post date:** [July 1, 2014, 8:35pm UTC](https://www.ruby-forum.com/t/setup-issue-cannot-load-java-jruby-1-7-13-window-7/230613/9 "2014-07-01T20:35:57Z")

</div>

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  
issue?

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

–  
View this message in context:  
[http://ruby.11.x6.nabble.com/setup-issue-Cannot-load-java-Jruby-1-7-13-window-7-tp5000589p5000712.html](http://ruby.11.x6.nabble.com/setup-issue-Cannot-load-java-Jruby-1-7-13-window-7-tp5000589p5000712.html)  
Sent from the JRuby - User mailing list archive at [Nabble.com](http://Nabble.com).
