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.
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.
You can check out a JRuby release as a NetBeans project from the JRuby repository.
However, if you use a publicly available version, you can perform the following steps to convert your existing JRuby into a Netbeans Project.
Download JRuby Sources:
1. Download the JRuby source code.
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.
4. At the Build and Run Actions page, specify the following ant targets in the fields listed below:
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.
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.
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.
The Projects window contains a project node for JRuby you have just created. Now you can develop JRuby within the NetBeans IDE.
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.
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: