title: Setting JAVA_HOME evironment variable in/for Ruby and RJB in windows
body: <p>Though there seem to be a bunch of questions and answers related to setting the JAVA_HOME variable in Windows, I am not entirely sure where I am going wrong. </p>
  
  <p>I've followed all sorts of different instructions on setting the environment variable, and when I check the environment variable in ruby I get</p>
  
  <pre>
  c:\Ruby192&gt;rib
  irb(main):001:0&gt; puts ENV['JAVA_HOME']
  "c:\progra~1\java\jdk1.6.0_20"
  =&gt; nil
  </pre>
  
  <p>So I have been interpreting this as the environment variable being set , as the path to my jdk is returned, but what is the 'nil'??</p>
  
  <pre>
  echo %JAVA_HOME%
  </pre>
  
  <p>also returns the path to my jdk. </p>
  
  <p>When I run </p>
  
  <pre>
  gem install rjb
  </pre>
  
  <p>I get </p>
  
  <pre>
  extconf.rb:39:in '(main)': JAVA_HOME is not a directory. (RuntimeError)
  </pre>
  
  <p>When I look in the extconf.rb file, sure enough, I've got</p>
  
  <pre>
  javahome = ENV['JAVA_HOME']
  if javahome.nil? && RUBY_PLATFORM =~ /darwin/
    javahome = `/usr/libexec/java_home`.strip
  end
  unless javahome.nil?
    if javahome[0] == ?" && javahome[-1] == ?"
      javahome = javahome[1..-2]
    end
    raise "JAVA_HOME is not directory." unless File.directory?(javahome)
    pt = Path.new
  </pre>
  
  <p>So from what I can tell, either the nil means that JAVA_HOME isn't being found, or I'm not pointing it to the right path or something. </p>
  
  <p>I've tried including the '\bin' to the end of the path, as some responses said that was necessary, but I get the same result. </p>
  
  <p>Any suggestions?</p>