About java integration

Hello, everyone

As i know, there are 2 ways to integrate java code in jruby

  1. call java code directly in jruby
  2. write a java extension for jruby

What difference between them and which is the better way to integrate
java code?

thanks

Your question is too broad and unclear to answer properly.

If you want to reuse Java classes, you need to “require ‘java’” and then
require whatever Java staff you want:
http://blogs.oracle.com/coolstuff/entry/using_java_classes_in_jruby
or
http://kenai.com/projects/jruby/pages/CallingJavaFromJRuby#Accessing_and_Importing_Java_Classes

If you want to run Ruby code from existing Java application then you can
use RedBridge:
http://kenai.com/projects/jruby/pages/RedBridge#Getting_Started

On Wed, Dec 28, 2011 at 10:41 AM, Dmytrii N. [email protected]
wrote:

Your question is too broad and unclear to answer properly.

If you want to reuse Java classes, you need to “require ‘java’” and then
require whatever Java staff you want:
http://blogs.oracle.com/coolstuff/entry/using_java_classes_in_jruby
or

http://kenai.com/projects/jruby/pages/CallingJavaFromJRuby#Accessing_and_Importing_Java_Classes

Thanks. Yes, i want to reuse Java classes in JRuby code. I think there
are 2 ways to do this. one is using ‘require java’ and the other is
writing a JRuby extension using java. I want to know the difference of
them

I think you should review Dmytrii’s links (although I think the wiki
pages
have moved to GitHub, see below). The pages do a pretty good job of
explaining what purposes they serve. If you’re in Java-land and want to
call into JRuby or enable a scripting environment like JRuby to be run
from
Java
, RedBridge is what you’re looking for. If you want to call Java
from
JRuby
, that’s pretty easy with the require ‘java’ piece. The only real
difference between the two is from which side of the fence you’re
looking
at the integration.

Embedding JRuby in Java - https://github.com/jruby/jruby/wiki/RedBridge
Calling Java from JRuby -
https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby

-Nick K.

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