Tuesday, February 12, 2013

Widgets

Introduction to JRuby

JRuby
JRuby is an implementation of Ruby which runs on top of Java Virtual Machine. JRuby code can be embedded in Java code and your JRuby code can interact with Java Objects and has access to every Java API.

Why to use JRuby?
Ruby being a scripting language is dynamic and much faster than Java. There are lot of things that can be easily accomplished in Ruby for example I found that parsing & scraping HTML is much easier and faster in Ruby using HPricot. As a Java programmer and you can write part of your application in JRuby and then either embed this in your Java code or use JRubyC compiler to convert your JRuby code in to Java.

Your first JRuby program

[ruby]
require 'rubygems'
class MyClass
def initialize()
end
def myfunction(msg)
puts msg;
end
end
MyClass.new.myfunction('Hello JRuby!');
[/ruby]

Executing the above code can be done using the following command
jruby

3 comments:

  1. Cool blog! Is your theme custom made or did you download it from somewhere?

    A theme like yours with a few simple adjustements would really make my blog stand out.
    Please let me know where you got your theme. With thanks

    ReplyDelete
  2. What's up to all, how is all, I think every one is getting more
    from this web page, and your views are nice in support of new
    users.

    ReplyDelete
  3. Undeniably imagine that which you said. Your favorite
    reason seemed to be at the internet the easiest factor
    to remember of. I say to you, I definitely get irked even as folks think
    about issues that they just don't recognize about. You controlled to
    hit the nail upon the highest and also defined out the whole thing with no need side-effects , other people could
    take a signal. Will probably be back to get more.
    Thank you

    ReplyDelete