Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(‘The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

August 12, 2006

Develop Ruby Applications Using Eclipse IDE

Filed under: GNU/Linux, Ruby/Rails — tabrez @ 1:10 pm

Eclipse is one of the most popular programming IDEs available today. Very few development environments can stand against it in terms of features or ease of use. Except for editing very small/few number of files, for which the fast responsiveness of the simple editors might be more desirable, Eclipse is becoming the most preferred development environment. Its flexible plugin system has allowed the community to work towards enhancing/adding new functionality to the core product, just like it happened with emacs. The open source license and the plugin system has aslo meant that the IDE today supports most of the popular programming languages making Eclipse far more that just a Java IDE. One such language supported by Eclipse with the support of plugins is Ruby. If you are a Ruby/Rails developer, then you must definitely give Eclipse + Ruby plugin a try.

Download and Install Eclipse

Skip this section if you already have Eclipse installed on your system.

One way to install Eclipse would be to use the appropriate package manager for your distribution like apt, emerge, yum, yast etc. If you want the latest version though, downloading it separately and uncompressing it in the home directory would be an ideal way. In this case, follow these steps:

  1. Download Eclipse from here.
  2. Extract the downloaded file in the home directory(say /home/user).
  3. Make sure atleast the Java runtime(JRE) is installed(complete Java SDK is required to create Java programs from Eclipse) on the system. Go to the extracted directory and run the ‘eclipse’ executable file to check if everything is working properly.

Downloading and Installing Ruby plugin for Eclipse

Follow these steps:

  1. Download the Ruby plugin for Eclipse by selecting a mirror from here
  2. Extract the downloaded file in a temporary directory(say /home/user/temp).
  3. Copy the contents of the extracted directory in the corresponding Eclipse folders:
    /home/user/temp/features/* —-> /home/user/eclipse/features/
    /home/user/temp/plugins/* —-> /home/user/eclipse/plugins/

    (Use the path to the Eclipse installation folder if its not installed in the home directory).

  4. Confirm if the Ruby plugin is successfully installed by starting the eclipse IDE and going to Help->About Eclipse SDK->Plug-in Details.
  5. Scroll down the list of installed plugins to find the Ruby plugin.

Configure the Ruby plugin

Before being able to create Ruby programs from Eclipse, we need to provide it with the information regarding where Ruby is installed. If Ruby is not already installed, then install it first. Then follow these steps:

  1. Start Eclipse IDE and go to Window->Preferances->Ruby->Installed Interpreters->Add.
  2. Enter the following details:
    Interpreter Name: ruby
    Location: /usr/bin/ruby

    To find the location where ruby is installed on your machine, run the following command:

    sh# which ruby
    /usr/bin/ruby

  3. Now go to Window->Preferances->Ruby->Ri/rdoc and enter the following information:
    RDoc Path: /usr/bin/rdoc
    Ri Path: /usr/bin/ri

  4. Fill whatever location you have found out in the earlier step using `which` command.

Creating a Sample Ruby Application From Eclipse

  1. To create a Ruby application, create a Ruby project from File->New->Project
  2. Select Ruby->Ruby Project. Click ‘Next’, enter a project name and click ‘Finish’.
  3. Select File->New->Ruby Class to create a new class or select File->New->File to create a simple Ruby file. Type a program in the editor and save it.
  4. Now right-click on the file name and select Run As->Ruby Application to run the script.
  5. You can also debug the Ruby programs from within Eclipse. Click the ‘Debug’ button on the toolbar and select a Ruby script to start debugging it.

    The debugger is started and ready.

Other excellent development environments for Ruby application development include Komodo IDE, Emacs, Vim, SciTE etc. I will try to write about these development environments in the next few posts.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Develop Ruby Applications Using SciTE Editor
  • Develop Ruby Applications Using Komodo IDE
  • Setting Up Rails Development Environment using Aptana Studio
  • Programming in Ruby Using SciTE – Windows Issues and Other Tips
  • Develop Ruby Applications Using JEdit Editor
  • EasyEclipse is the Best Packaged Distribution of Eclipse Platform
  • “Hello, World” Web Application in Ruby on Rails using Aptana Studio


  • 8 Comments »

    1. [...] If RADRails doesn’t capture your fancy and you’d rather use regular Eclipse as your Ruby IDE, Tabrez Iqbal has a great walkthrough of setting up Eclipse and using it to develop Ruby applications along with lots of screenshots and useful information. [...]

      Quote

      Pingback by How to use the Eclipse IDE to develop Ruby applications — August 16, 2006 @ 12:11 am

    2. [...] Every Flavour Beans » Develop Ruby Applications Using Eclipse IDE (tags: ruby) [...]

      Quote

      Pingback by Ross Notes » Blog Archive » links for 2006-08-16 — August 16, 2006 @ 5:55 pm

    3. hi there,

      nice article.

      I use Xemacs on windows XP/2000. I run the shell and run irb from within it and another shell for executing a program outside of irb.

      It will be nice to see what modes people use X/Emacs with ? Are there pre-built versions that are easy for windows developers ?

      thank you,

      BR,
      ~A

      Quote

      Comment by anjan bacchu — August 17, 2006 @ 2:47 am

    4. hi there,

      I got an email saying someone commented on this post — found that it was SPAM.
      Good that you guys removed it.

      You probably want to send emails to whoever’s subscribed ONLY after confirming that a comment
      is NOT SPAM.

      thank you,

      BR,
      ~A

      Quote

      Comment by anjan bacchu — September 27, 2006 @ 3:05 pm

    5. I am really sorry for the email you got because of the spam comment posted here. It’s a good point that you have made regarding the plugin’s behaviour regarding sending the email alerts. I will forward your suggestion to the author of this plugin and let’s see what he/she has to say about it.

      Thanks for the suggestion.

      Quote

      Comment by tabrez — September 27, 2006 @ 9:12 pm

    6. Hi,
      I have been stuck on installing/configuring RDT within my Eclipse IDE. Apparently the RDT plugin has been installed successfully, the files copied on the /features and /plugins directories respectively. I however do NOT see a Ruby section when I got to Windows>preferences in Eclipse. I have attempted the installation/configuration procedure a couple of times as well as used the software updates>find and install approach to no avail. What please am I doing wrong and what can I do? Rails however appear within the preferences window

      Quote

      Comment by ire — November 28, 2006 @ 7:21 pm

    7. It is always messy installing the plugins in Eclipse to add more functionality. The software is very sensitive to the version of Eclipse and the versions of the plugins used. I suggest trying the following prepackaged Eclipse IDEs for Ruby and Rails development:

      1. RadRails
      2. EasyEclipse

      RadRails is only for Ruby and Rails where as EasyEclipse has many flavours to suit different needs. Pick the one that best suits your requirements. Installing additional plugins in EasyEclipse has never given me a problem until now. If you decide to try out EasyEclipse, you must go through the following distribution/plugin chart:
      EasyEclipse Distribution/Plugin Chart

      Quote

      Comment by tabrez — November 30, 2006 @ 2:50 pm

    8. thank you for this little tuto, simple &
      very useful
      and it works (on winxp)
      i have read many tuto before as a’m a ruby newbie
      most are wrong, brokens links…
      i’m happy to try it now
      JL

      Quote

      Comment by legendre — March 5, 2007 @ 11:31 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost