# Running Java from Rails

**URL:** <https://www.ruby-forum.com/t/running-java-from-rails/85325>\
**Category:** Ruby\
**Created:** [February 12, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325 "2007-02-12T17:41:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/1 "2007-02-12T17:41:32Z")

</div>

Does anyone know of a possibility to run Java-Classes out of RoR (e.g.  
use java objects in a ruby context)?

I’m a newbie regarding RoR coming from Java-Land and I’m asking myself  
if there’s an easy way for me to code all the complex stuff in Java  
and use it in RoR.

Thanx for your help!

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 5:47pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/2 "2007-02-12T17:47:32Z")

</div>

Javier\_CH wrote:

> Does anyone know of a possibility to run Java-Classes out of RoR (e.g.  
> use java objects in a ruby context)?
> 
> I’m a newbie regarding RoR coming from Java-Land and I’m asking myself  
> if there’s an easy way for me to code all the complex stuff in Java  
> and use it in RoR.
> 
> Thanx for your help!

Coming from Java, let me tell you that coding the “complex stuff” in  
ruby is much nicer than coding it in Java IMO. Take the time to learn  
ruby and you will be extremely happy.

-Drew

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 5:49pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/3 "2007-02-12T17:49:33Z")

</div>

I don’t know if there is such a way, but I think that you’d be losing  
all the benefit of Ruby by doing the complex stuff (or anything, really)  
in Java.

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 6:20pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/4 "2007-02-12T18:20:36Z")

</div>

On 12 Feb., 17:47, Drew O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Coming from Java, let me tell you that coding the “complex stuff” in  
> ruby is much nicer than coding it in Java IMO. Take the time to learn  
> ruby and you will be extremely happy.

You’re right, but I think bytecode is probably faster then interpreted-  
code when it comes to performance. What have your experiences been?

Second, we’ve a information retrieval project written in java (lucene)  
which I’d like to use and I don’t think using it over a webservice is  
an option…

Thanks for your replies.

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/5 "2007-02-12T18:08:35Z")

</div>

On Feb 12, 2007, at 10:40 AM, Javier\_CH wrote:

> Does anyone know of a possibility to run Java-Classes out of RoR (e.g.  
> use java objects in a ruby context)?
> 
> I’m a newbie regarding RoR coming from Java-Land and I’m asking myself  
> if there’s an easy way for me to code all the complex stuff in Java  
> and use it in RoR.

I’m using RJB[1] to call a Java RMI client that talks to our backend  
Java code. Working pretty well thus far. The maintainer is pretty  
response too.

[1] [http://rjb.rubyforge.org/](http://rjb.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 6:38pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/6 "2007-02-12T18:38:39Z")

</div>

Thought I’d just weigh in here…

Javier\_CH wrote:

> On 12 Feb., 17:47, Drew O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Coming from Java, let me tell you that coding the “complex stuff” in  
> > ruby is much nicer than coding it in Java IMO. Take the time to learn  
> > ruby and you will be extremely happy.
> 
> You’re right, but I think bytecode is probably faster then interpreted-  
> code when it comes to performance. What have your experiences been?  
> Firstly, the chances are that it doesn’t matter - developer speed beats  
> cpu speed in general. Secondly, you’re probably right, but benchmark it

- don’t guess.

> Second, we’ve a information retrieval project written in java (lucene)  
> which I’d like to use and I don’t think using it over a webservice is  
> an option…  
> If you’re interested in Lucene but don’t need any of the Lucene-specific  
> tools, it’s really worth having a look at Ferret. It’s a Lucene-alike  
> written in C with Ruby bindings, and it’s very, very good.

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 7:25pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/7 "2007-02-12T19:25:47Z")

</div>

Hi,

On 2/12/07, Javier\_CH [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does anyone know of a possibility to run Java-Classes out of RoR (e.g.  
> use java objects in a ruby context)?

Could this be something for JRuby?  
[http://jruby.codehaus.org](http://jruby.codehaus.org)

I’ve not done anything with it, but looking at the site it seems like it  
may  
be possible.  
[http://jruby.codehaus.org/Java+Integration](http://jruby.codehaus.org/Java+Integration)

I’m a newbie regarding RoR coming from Java-Land and I’m asking myself

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 6:45pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/8 "2007-02-12T18:45:41Z")

</div>

Or, optionally, Ruby can work with Solr, a Lucene based search service.

[http://wiki.apache.org/solr/SolRuby](http://wiki.apache.org/solr/SolRuby)

–Jeremy

On 2/12/07, Alex Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Firstly, the chances are that it doesn’t matter - developer speed beats  
> Hope this helps 🙂
> 
> –  
> Alex

–  
[http://www.jeremymcanally.com/](http://www.jeremymcanally.com/)

My free Ruby e-book:  
[http://www.humblelittlerubybook.com/book/](http://www.humblelittlerubybook.com/book/)

My blogs:

> **[Site not found · DreamHost](http://www.mrneighborly.com/)**
>
> The owner of this domain has not yet uploaded their website.

[http://www.rubyinpractice.com/](http://www.rubyinpractice.com/)

---

<div class="post-metadata">

**Author:** ![Javier\_CH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Javier\_CH](https://www.ruby-forum.com/u/Javier_CH)\
**Post date:** [February 12, 2007, 7:49pm UTC](https://www.ruby-forum.com/t/running-java-from-rails/85325/9 "2007-02-12T19:49:50Z")

</div>

On 2/12/07, Javier\_CH [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 12 Feb., 17:47, Drew O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Coming from Java, let me tell you that coding the “complex stuff” in  
> > ruby is much nicer than coding it in Java IMO. Take the time to learn  
> > ruby and you will be extremely happy.
> 
> You’re right, but I think bytecode is probably faster then interpreted-  
> code when it comes to performance. What have your experiences been?

This is premature optimisation. Which in engineering terms is a great  
way to ruin a project. Its not like Rails insists that everything is  
written in Rails/Ruby anyway.

A lot of the CPU intensive stuff, like funky graphics stuff is typically  
handed over to binary stuff anyway.

> Second, we’ve a information retrieval project written in java (lucene)  
> which I’d like to use and I don’t think using it over a webservice is  
> an option…

Well look at JRuby. It seems to be what you need, though it is a bit  
early to consider running a full Rails install on it. It just about runs  
Rails, which is probably a by-word for ‘but not in a mission critical  
environment’.

The JRuby guys are pretty sharp though, and I don’t expect that  
situation to stay that way for long.
