I’m having an issue executing jruby from the mingw git bash shell in windows. I downloaded the windows installer for jruby 1.6.2 and ran it without issue. If I open a new windows cmd shell it seems to work fine. I installed the rake and sinatra gems; used the irb. entering jruby -v gets:
jruby 1.6.2 (ruby-1.8.7-p330) (2011-05-23 e2ea975) (Java HotSpot(TM) Client VM 1.6.0_24) [Windows 7-x86-java]
However, when I open the git mingw bash shell and attempt to do anything with jruby I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
Caused by: java.lang.ClassNotFoundException: org.jruby.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.jruby.Main. Program will exit.
I have made sure that the jruby lib directory is in the classpath.
Any other ideas?
UPDATE:
I think the issue is the shell scripts that end up invoking the jar in the jruby bin directory.
The issue is that while msys can transform POSIX to Win paths for most things, but the script builds up strings on its own in order to pass classpath and other information to the jar.
It appears that this is where things are getting messed up. The scripts specifically have branches of code that deal with cygwin for this same reason. I attempted to force the scripts to to think that it was running under cygwin but unfortunately the scripts make use of the “cygpath” program to get the paths and that is not available in msys
Turns out is was indeed a “missing feature” of the bash scripts. I submitted a bug to the jruby jira and it was resolved
https://jira.codehaus.org/browse/JRUBY-5864
Note that as of the time of this writing that commit has not been part of the build that’s available for download on the jruby web site. But the fix was quite simple.
Here is the commit: https://github.com/jruby/jruby/commit/8766f84b774ae5ae68204931bd4eab61b81a2056
All it is is adding the following to the uname case at the top of the jruby.bash file