Declaring java package and method signature in JRuby

jruby3

We can add the package declaration for the java classes generated by JRubyc by using java_package. Just add the following line before the JRuby class declaration java_package 'package name' And also make sure you have included the statement require 'java'. Now once you convert the code using jrubyc you will find that the package structure is automatically created. Similarly you can declare signatures for java methods using java_signature 'put method signature here' Now … [Read more...]

Converting JRuby to Java

jrubyc1

Now that we know how to write a basic JRuby code lets see how to convert the JRuby code in to Java code. JRuby comes with JRubyc a cross compiler that does the magic! Convert to Java code Convert JRuby Java class files Okay great! now you have Java source class for your JRuby class but what if you want to declare package and method signature for the generated java class? … [Read more...]

Introduction to JRuby

jruby1

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 … [Read more...]