NetbeansedJRuby

How to Work with JRuby in the NetBeans IDE </div>

By: Daria Titova, with contributions of PCM Reddy and Mikhail Vaysman

May 2007

In this tutorial, you will convert JRuby to a NetBeans project and learn how to build and perform test-runs of JRuby projects in the NetBeans IDE. </span>

Contents


Introduction

JRuby is a 100% pure Java implementation of the famous Ruby programming language, which is a dynamic, open-source language focused on simplicity and productivity. Ruby has an elegant syntax that is natural to read and easy to write.
This tutorial shows you how to use the NetBeans IDE for JRuby development.

The NetBeans Integrated Development Environment (IDE) is a free, open-source Integrated Development Environment for software developers. The NetBeans IDE provides developers with all the tools they need to create professional cross-platform desktop, enterprise, web, and mobile applications. In this tutorial, you learn how to convert a JRuby project to a Netbeans project to develop, build, and test JRuby within the Netbeans IDE.

For more information on how to work with the NetBeans IDE, see the Support and Docs page.

Software needed

Before you begin, you need to install the following software on your computer: NetBeans IDE 6.0.
Since NetBeans 6.0 is under development now, use NetBeans IDE 6.0 Preview (M9) available from NetBeans IDE 6.0 Preview (M9) Download or check the latest working version at http://bits.nbextras.org/netbeans/6.0/nightly/.

Notations used in this documentation

  • <NETBEANS_HOME> - the NetBeans IDE installation directory
  • <USER_HOME> - the user's home directory. Example: "C:\Documents and Settings\user_home"
  • <jruby_src_root> - directory with the JRuby sources.

Exercises

You can check out a JRuby release as a NetBeans project from the JRuby repository at https://svn.codehaus.org/jruby/.

However, if you use a publicly available version (for example http://dist.codehaus.org/jruby/jruby-src-0.9.8.tar.gz), you can perform the following steps to convert your existing JRuby into a Netbeans Project.

Converting JRuby to a Netbeans Project

Download JRuby Sources:

1. Download the JRuby source code from http://dist.codehaus.org/jruby/. This tutorial uses http://dist.codehaus.org/jruby/jruby-src-0.9.8.tar.gz.

2. Extract the files from this archive to the
<jruby_src_root>
directory. 3. Replace
ant.jar
located in the {<jruby_src_root>/lib} directory with ant.jar version 1.6.5 or newer. This step is required because of the following JRuby's known bug: "The existing
ant.jar
is an old 1.5 version."

Creating the JRuby NetBeans Project:

1. From the main menu, choose File > New Project.
The New Project wizard opens.

2. In the Categories list, select "Java Project with existing ANT Script" and click Next.

3. At the Name and Location page, specify the locations of JRuby's project files and the build.xml file. In our case, the JRuby project files are at
C:\tmp\jruby-0.9.8
.

Image:project-existing-ant_NetbeansedJRuby.jpg

Click Next.

4. At the Build and Run Actions page, specify the following ant targets in the fields listed below:

  • Build Project - jar
  • Clean Project - clean
  • Generate Javadoc - create-apidocs
  • Run Project - leave this field empty
  • Test Project - test

Image:project-actions_NetbeansedJRuby.jpg

Click Next.

5. At the Source Package Folders page of the wizard, specify
<jruby_src_root>/src
as the source package folder and {<jruby_src_root>/test} as the test package folder.

Image:project-source_NetbeansedJRuby.jpg

Click Next.

6. At the Java Sources Classpath page, add all .jar files and folders under the
<jruby_src_root>/lib
directory to the Java Sources Classpath list.

Image:project-classpath-src_NetbeansedJRuby.jpg

7. Select the test source package folder and add the bsf.jar, and junit.jar files under the <jruby_src_root>/lib directory and the src folder to the Java Sources Classpath list.

Image:project-classpath_NetbeansedJRuby.jpg

Click Finish.

The Projects window contains a project node for JRuby you have just created. Now you can develop JRuby within the NetBeans IDE.


Building the JRuby Project

To build a jruby.jar, do the following:

1. In the Projects window, right-click the JRuby project node and choose Build Project or Clean and Build Project from the pop-up menu.

Image:build-pr_NetbeansedJRuby.jpg

The JRuby .jar file will be built and you will see the "BUILD SUCCESSFUL" message in the Output window.

Image:building-jruby1_NetbeansedJRuby.jpg


Testing the JRuby Project

To perform testing of the JRuby project, do the following:

1. In the Projects window, right-click the JRuby project node and choose Test Project from the pop-up menu, or press Alt+F6.

Image:test-pr_NetbeansedJRuby.jpg

A test run of the JRuby project is performed and you see test results in the JUnit Test Result and Output windows.

Summary

In this tutorial, you learned how to start JRuby development in the NetBeans IDE. You have completed the following exercises:

  • Convert JRuby into Netbeans Project.
  • Build JRuby in NetBeans IDE.
  • Test JRuby in NetBeans IDE.

See Also

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo