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>



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

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.


You can check out a JRuby release as a NetBeans project from the JRuby repository at

However, if you use a publicly available version (for example, 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 This tutorial uses

2. Extract the files from this archive to the
directory. 3. Replace
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
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


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


Click Next.

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


Click Next.

6. At the Java Sources Classpath page, add all .jar files and folders under the
directory to the Java Sources Classpath list.


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.


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.


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


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.


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


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