Canonical method to check for jruby

I have:

if RUBY_PLATFORM =~ /java/
#do jruby specific thing here
else
#do mri specific thing here
end

in my code in a couple of places, so that it can run on mongrel or
Glassfish. I was wondering if that’s the best way to do it?

-Matt McKnight-
LMN Solutions, Inc.
[email protected]
www.lmnsolutions.com

Hi Matthew,

Yes, this is one of the most wildly used methods, but it has one
drawback – it’s not guaranteed to work forever, since one day the
RUBY_PLATFORM value might change (unlikely, but possible). Not to
mention that any other java-based implementation of Ruby might also
satisfy that check.

The canonical and 100% reliable way to detect JRuby is:
if defined? JRUBY_VERSION

Thanks,
–Vladimir

On Thu, Jul 24, 2008 at 7:23 PM, Matthew McKnight
[email protected] wrote:

-Matt McKnight-
LMN Solutions, Inc.
[email protected]
www.lmnsolutions.com


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs