Develop Ruby Code with Eclipse (April 17, 2011)

Posted: April 17, 2011 by Mike Hubbartt in Development
Tags: , , ,

By Mike Hubbartt, Copyright 2011, All Rights Reserved.

This brief tutorial is meant to help people get started writing their first Ruby program using the Eclipse IDE.

Step 1: See if Ruby is already installed.

Ruby does ship with some operating systems, however it is available for multiple operating systems here.

  1. To verify it is installed on your Mac, launch Terminal and enter ‘irb’ to start interactive Ruby. If the prompt changes to ‘>>’, enter a simple Hello World program like ‘puts “Hello Ruby on Mac world!”’
  2. To verify it is installed on your Linux computer, open a shell and enter ‘irb’ and , enter a simple Hello World program like ‘puts “Hello Ruby on Linux!”’.
  3. If you have a Windows computer, you need to download and install Ruby, then follow the instructions to test Interactive Ruby on Windows here.

Step 2: Get setup with Eclipse

  1. Download and install Eclipse if you don’t already have it.
  2. Launch Eclipse, then locate and install the Ruby Development Tools plug-in using the Eclipse ‘Help/Install New Software’ menu option. At the Available Software dialog box:
    1. Select –All Available Sites– for the ‘Work with’ drop down list.
    2. Expand the Programming Languages section and select ‘Dynamic Languages Toolkit – Ruby Development Tools’.
    3. Press the Next button, review the options, then select the Finish button.
  3. Use the IDE ‘Eclipse/Preferences’ menu option to pull up the application preferences dialog, then select ‘Ruby’ on the far right of the dialog.
    1. Expand the options under ‘Ruby’ and select ‘Interpreters’. If none are displayed, select the ‘Search…’ button at the right side of the screen to locate any installed interpreters. Apple ships a ruby interpreter – in OSX 10.5.x I found them in /usr/bin/ruby.
  4. Now use the IDE ‘File/New/Ruby Project’ to create a new Ruby project. Name it to any convention you follow (type of project, class, etc.).
    NOTE: You want to use the Ruby Perspective when writing Ruby code, which is available using the IDE ‘Window/Open Perspective/Other’ option and selecting ‘Ruby from the list.
  5. Select ‘File/New/Ruby Class’ to create your first Ruby program. Name it hello, then enter this simple Hello World program to confirm you can create and run a Ruby program:

    class hello
    def hello
    puts “Hello Ruby World”
  6. Save and execute the file and verify you see the text string in the Eclipse console. Congratulations. You just created your first Ruby program using Eclipse.
  1. Jag says:

    Can you please elaborate on this:

    Launch Eclipse, then locate and install the Ruby Development Tools plug-in using the Eclipse ‘Help/Install New Software’ menu option.


  2. Milind says:

    thank you so mch..i made a great help.i am using VMPlayer for rails and was looking for and IDE for development…this article helped me,,,

  3. ccdude53 says:

    Creating this class with the puts statement does not work on my installation. The generic ‘print’ does. Not sure as a newbie what it different but maybe this needs to be refactored.

    • I’ll see if I can help if you can provide more information.

      1. Did you use ‘puts’ in the examples in step 1, step 2, or both steps 1 & 2?
      2. Which OS are you running? I’m running OSX 10.6.8 and ‘puts’ works but ‘put’ does not.
      3. Another thing to check: which version of interactive Ruby are you running?
      4. Which IDE are you using, and which version of that particular IDE?

  4. fmp says:

    i got this problem when i try to run the hello.rb code.

    Problem Occured: Testing Engine not configured for this launch configuration.

    Do you know how to fix this?

    Mac OSX 10.7.2 / 2.3Ghz i5 / 8GB

    • Could you do Step 1 in this post to verify Ruby is installed? I do not have Lion installed to be able to test, but maybe one of our readers running Lion will be able to help.

      – Mike

    • Mask says:

      Use the IDE ‘Eclipse/Run’ menu option to pull up the Debug Configurations dialog, expand Ruby Test, Select Hello.rb and pick “Test::Unit” from the Ruby Testing Engine selection.
      Apply your changes and debug the code.

  5. Glen says:

    I have the same question as fmp. Did anyone ever figure this out? I have ruby installed and the interpreters set but it still says “No testing engine configured”

  6. Stephen Campbell says:

    I’m using OSx Lion and eclipse indigo, but when i execute the program nothing appears in the console.

    Anyone have any ideas?

  7. Greg Chambers says:

    I got it to work by commenting out everything but the puts line:

    ##class Hello
    ## def hello
    puts “Hello Ruby World”
    ## end

    To run it:
    Right click on the “hello.rb” file
    Choose “Run As”
    Choose “Ruby Script”
    Click on the Console tab to view the results.

    • RubyFan says:

      # declare class
      class Hello
      def hello
      puts “Hello Ruby world”

      # now create object
      a =
      a.hello() # invoke method hello -> this print out “Hello Ruby world”

      • DH says:

        I guess one has to instantiate the object and call the method as shown by RubyFan above. This posting is useful, but the code should be fixed as shown above.

  8. […] Decided to attempt to get Ruby working in an Eclipse environment.  I am using as my tutorial an article from Digerati and Technology Reports (April 17 2011) by Mike Hubbartt and can be found here. […]

  9. Thank you Mike fo this very simple and very useful tutorial. Everything worked well (first step worked and all subsequent ones). The only thing is that after running the program, the only thing I see in the console is that the program has been ran and there is no error but the window is blank; I don’t have any output in the console: I do not see the output message “Hello Ruby World”. Any idea why that is happening? (I use “Ruby 1.9.3” and I use “Eclipse IDE for C/C++ Developers, Version: Juno Service Release 1”)

  10. Alright, it works all fine by simply writing :
    class Helloagain
    puts “Hello Ruby World”

  11. anonimus says:

    But did you try to edit .erb files with it? It doesn’t work. It works only for “class A end” and “def b end” things. Almost any editor can do it.

  12. Ganapthi LN says:

    Hi Mike,

    Clear and nice post for Ruby. I am neebe for ruby. I have iMac. But eclipse not installed.
    Now am using Eclipse -Indigo in windows 7. I have decent knowledge in PHP..I willing to know Ruby.I will try now. For ruby development guides need your support. Thanks in advance.

  13. carlosgut70 says:

    Good post. I’ll refer it. Everithing works fine with the right ruby code. Congrats.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s