# Running Java from Rails

**URL:** <https://rubytalk.org/t/running-java-from-rails/35297>\
**Category:** ruby-talk\
**Created:** [12 February 2007 16:40 UTC](https://rubytalk.org/t/running-java-from-rails/35297 "2007-02-12T16:40:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Vazquez](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@Javier\_Vazquez](https://rubytalk.org/u/Javier_Vazquez)\
**Post date:** [12 February 2007 16:40 UTC](https://rubytalk.org/t/running-java-from-rails/35297/1 "2007-02-12T16:40:09Z")

</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:** ![Drew\_Olson](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Drew\_Olson](https://rubytalk.org/u/Drew_Olson)\
**Post date:** [12 February 2007 16:47 UTC](https://rubytalk.org/t/running-java-from-rails/35297/2 "2007-02-12T16:47:45Z")

</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

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Sammy\_Larbi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sammy\_Larbi](https://rubytalk.org/u/Sammy_Larbi)\
**Post date:** [12 February 2007 16:49 UTC](https://rubytalk.org/t/running-java-from-rails/35297/3 "2007-02-12T16:49:04Z")

</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.

Javier\_CH wrote, On 2/12/2007 10:40 AM:

> **···**
>
> > 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:** ![Adam\_Keys](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@Adam\_Keys](https://rubytalk.org/u/Adam_Keys)\
**Post date:** [12 February 2007 17:07 UTC](https://rubytalk.org/t/running-java-from-rails/35297/4 "2007-02-12T17:07:22Z")

</div>

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/)

> **···**
>
> 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.
> 
> --  
> ~akk
> 
> > **[Adam Keys is typing](https://therealadam.com/)**
> >
> > Developer and engineering manager at large

---

<div class="post-metadata">

**Author:** ![Michael\_Guterl1](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@Michael\_Guterl1](https://rubytalk.org/u/Michael_Guterl1)\
**Post date:** [12 February 2007 18:25 UTC](https://rubytalk.org/t/running-java-from-rails/35297/5 "2007-02-12T18:25:31Z")

</div>

Hi,

> 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

> **···**
>
> On 2/12/07, Javier\_CH \<vazqujav@gmail.com\> wrote:
> 
> > 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!
> 
> --  
> Michael Guterl

---

<div class="post-metadata">

**Author:** ![Javier\_Vazquez](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@Javier\_Vazquez](https://rubytalk.org/u/Javier_Vazquez)\
**Post date:** [12 February 2007 17:20 UTC](https://rubytalk.org/t/running-java-from-rails/35297/6 "2007-02-12T17:20:14Z")

</div>

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.

> **···**
>
> On 12 Feb., 17:47, Drew Olson \<olso...@gmail.com\> 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.

---

<div class="post-metadata">

**Author:** ![Alex\_Young](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Alex\_Young](https://rubytalk.org/u/Alex_Young)\
**Post date:** [12 February 2007 17:37 UTC](https://rubytalk.org/t/running-java-from-rails/35297/7 "2007-02-12T17:37:56Z")

</div>

Thought I'd just weigh in here...

Javier\_CH 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 🙂

> **···**
>
> > On 12 Feb., 17:47, Drew Olson \<olso...@gmail.com\> wrote:
> 
> --  
> Alex

---

<div class="post-metadata">

**Author:** ![Richard\_Conroy1](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@Richard\_Conroy1](https://rubytalk.org/u/Richard_Conroy1)\
**Post date:** [12 February 2007 18:48 UTC](https://rubytalk.org/t/running-java-from-rails/35297/8 "2007-02-12T18:48:28Z")

</div>

> \> 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.

> **···**
>
> On 2/12/07, Javier\_CH \<vazqujav@gmail.com\> wrote:
> 
> > On 12 Feb., 17:47, Drew Olson \<olso...@gmail.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Jeremy\_McAnally1](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jeremy\_McAnally1](https://rubytalk.org/u/Jeremy_McAnally1)\
**Post date:** [12 February 2007 17:44 UTC](https://rubytalk.org/t/running-java-from-rails/35297/9 "2007-02-12T17:44:55Z")

</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 Young \<alex@blackkettle.org\> wrote:
> 
> > Thought I'd just weigh in here...
> > 
> > Javier\_CH wrote:  
> > \> On 12 Feb., 17:47, Drew Olson \<olso...@gmail.com\> 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 🙂
> > 
> > --  
> > 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/)
