# Calling java function from JRuby

**URL:** <https://www.ruby-forum.com/t/calling-java-function-from-jruby/166205>\
**Category:** Ruby\
**Created:** [April 22, 2009, 7:09pm UTC](https://www.ruby-forum.com/t/calling-java-function-from-jruby/166205 "2009-04-22T19:09:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amabdelsalam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/958977/32.png) [@amabdelsalam](https://www.ruby-forum.com/u/amabdelsalam)\
**Post date:** [April 22, 2009, 7:09pm UTC](https://www.ruby-forum.com/t/calling-java-function-from-jruby/166205/1 "2009-04-22T19:09:31Z")

</div>

Hi,…

I’d like to call java function from inside JRuby. For example, when a  
certain event happen inside JRuby script, the java function is executed.

To simplify it:  
Here is some ruby code:  
def handle\_value(value)

# I want to send value to the java function to handle it

end

Here is a java function  
void handle\_value(String value)  
{  
System.out.println("value = " + value);  
}

Any help please?

Regards,…

Ahmed

---

<div class="post-metadata">

**Author:** ![amabdelsalam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/958977/32.png) [@amabdelsalam](https://www.ruby-forum.com/u/amabdelsalam)\
**Post date:** [April 22, 2009, 7:44pm UTC](https://www.ruby-forum.com/t/calling-java-function-from-jruby/166205/2 "2009-04-22T19:44:42Z")

</div>

On Wed, Apr 22, 2009 at 12:09 PM, Ahmed A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Here is a java function  
> void handle\_value(String value)  
> {  
> System.out.println("value = " + value);  
> }
> 
> Any help please?

> **[LMGTFY - Let Me Google That For You](https://lmgtfy.app/?q=calling%2Bjava%2Bfrom%2Bjruby)**
>
> For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.

Cheers,  
/Nick

---

<div class="post-metadata">

**Author:** ![amabdelsalam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/958977/32.png) [@amabdelsalam](https://www.ruby-forum.com/u/amabdelsalam)\
**Post date:** [June 6, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/calling-java-function-from-jruby/166205/3 "2009-06-06T15:26:06Z")

</div>

“Nick S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) schrieb im Newsbeitrag

> http:// DONT\_USE\_THIS\_LINK!!!  
> [lmgtfy.com/?q=calling+java+from+jruby](http://lmgtfy.com/?q=calling+java+from+jruby)

Have you tried this request before posting this link here?  
Did you know every Google search request wastes the same energy as an  
11-watt energy saver lightbulb in an hour? Some people will have clicked  
this link and watched what happens.

So you will have sent some african village into darkness.

I think lmgtfy website is really funny, but should not be used.

Michael B.

---

<div class="post-metadata">

**Author:** ![amabdelsalam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/958977/32.png) [@amabdelsalam](https://www.ruby-forum.com/u/amabdelsalam)\
**Post date:** [June 6, 2009, 5:00pm UTC](https://www.ruby-forum.com/t/calling-java-function-from-jruby/166205/4 "2009-06-06T17:00:23Z")

</div>

> Did you know every Google search request wastes the same energy as an  
> 11-watt energy saver lightbulb in an hour? Some people will have clicked  
> this link and watched what happens.

Do you happen to know how much energy was wasted by my entirely  
pointless reply to your insightful message?
