简体   繁体   中英

Can JRuby use original Ruby gems?

I am considering about what is the difference between JRuby on Rails and the original Ruby on Rails for my product?

How does it difference in development activity, deployment, support between its original, or scalability?

I have read many article. They said JRuby is the same function like Ruby. Does it mean we can use Ruby gems for JRuby, using scaffold and ActiveRecord like Ruby, and we can also deploy the product like Java?

Only gems written purely in Ruby will work under JRuby. Gems like RMagick or MySQL or (the standard implementation of) JSON that require C extensions will leave you out of luck in some cases and with alternatives like the JDBC MySQL and JSON-JRuby gems in other cases.

See my answer here

Also, this is a handy reference: Is It JRuby

Most, but not all, Ruby gems are also available for JRuby. Scaffold and ActiveRecord can definitely be used with JRuby. You won't find any RoR functionality that is missing from the JRuby on Rails.

With JRuby you can deploy your application as a standard WAR . If you do not know for sure if you want to use native Ruby or JRuby, I recommend that you use Netbeans IDE. With it you can easily switch from native Ruby to JRuby for Rails applications.

JRuby is a full implementation of Ruby, they're the same but JRuby runs on the JVM. It scale very well because you can deploy it inside an application server like Glassfish or JBoss.

You can use Rails of course, there's only one configuration to do, the database adapter. You must install JDBC adapter for ActiveRecord, for example:

gem install activerecord-jdbcmysql-adapter

and in your database.yml

adapter: jdbcmysql

and you're done!

edit:

if you're interested there's a comparison between various Ruby implementations, http://www.infoq.com/presentations/seifer-ruby-vm-comparison and JRuby is one of the best implementation.

You don't have to re-install all your gems for JRuby. All you have to do is to set the GEM_HOME environment variable to the path with your gems. Please also note, that JRuby doesn't support native extensions. So you'll have to find JRuby compatible replacements for gems that use native extensions.

You can read this JRuby description

there is some text about ruby gem and how cloud jruby use them:

Many Gems will work fine in JRuby; however, some Gems build native C libraries as part of their install process. These Gems will not work in JRuby unless the Gem has also provided a Java equivalent to the native library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM