Miles to go …

September 7, 2007

TOTD #7: Switch between JRuby and CRuby interpreter in NetBeans 6

Filed under: netbeans, totd, web2.0 — arungupta @ 2:41 pm

The NetBeans 6 IDE comes pre-configured with JRuby interpreter. This TOTD explains how the JRuby interpreter can be swapped with a C-based Ruby interpreter and vice versa.

  1. Verify the JRuby interpreter
    1. Create a Rails Hello World using NetBeans 6 IDE.
    2. Expand "Views", "say", and open "hello.rhtml".
    3. Right-click in the "hello.rhtml" window and select "Run File" (Shift+F6 is the default shortcut). This starts the WEBrick container and displays "http://localhost:3000/say/hello". It shows the following in the output window:

      => Booting WEBrick...
      => Rails application started on http://0.0.0.0:3000
      => Ctrl-C to shutdown server; call with --help for options
      [2007-09-07 13:40:29] INFO WEBrick 1.3.1
      [2007-09-07 13:40:29] INFO ruby 1.8.5 (2007-09-06) [java]
      [2007-09-07 13:40:29] INFO WEBrick::HTTPServer#start: pid=6336176 port=3000
      127.0.0.1 - - [07/Sep/2007:13:40:33 PDT]  "GET /say/hello HTTP/1.1" 200 83
      - -> /say/hello

  2. Switch to C-based Ruby interpreter
    1. Download and install C-based Ruby interpreter (say RUBY_HOME).
    2. Install Rails gem by giving the following command in RUBY_HOME\bin directory:

      ruby -S gem install rails -y --no-rdoc

    3. In the NetBeans IDE "Tools" menu, select "Options", "Ruby", and change the value of "Ruby Interpreter" from

      to

    4. Stop the already running WEBrick server by clicking on the "x" in the bottom right corner of the IDE.

    5. Right-click in the "hello.rhtml" window and select "Run File" (Shift+F6 is the default shortcut). This starts the WEBrick container using the C-based Ruby interpreter and displays "http://localhost:3000/say/hello". It shows the following in the output window:

      => Booting WEBrick...
      [2007-09-07 14:13:54] INFO WEBrick 1.3.1
      => Rails application started on http://0.0.0.0:3000
      => Ctrl-C to shutdown server; call with --help for options
      [2007-09-07 14:13:54] INFO ruby 1.8.6 (2007-03-13) [i386-mswin32]
      [2007-09-07 14:13:54] INFO WEBrick::HTTPServer#start: pid=3900 port=3000
      127.0.0.1 - - [07/Sep/2007:14:13:56 Pacific Daylight Time] "GET /say/hello HTTP/1.1" 200 83
      - -> /say/hello
      127.0.0.1 - - [07/Sep/2007:14:14:20 Pacific Daylight Time] "GET /say/hello HTTP/1.1" 200 83
      - -> /say/hello

Of course, you can switch back to the JRuby interpreter using the same mechanism.

Please leave suggestions on other TOTD that you’d like to see. A complete archive is available here.

Technorati: totd rubyonrails jruby ruby netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. TOTD #24: Getting Started with Rails 2.0.x in JRuby 1.0.3 and JRuby 1.1RC1
  2. TOTD #13: Setup Mongrel for JRuby-on-Rails applications on Windows
  3. TOTD #27: Configurable Multiple Ruby Platforms in NetBeans 6.1 M1
  4. Ask The “JRuby + NetBeans + GlassFish” Experts
  5. TOTD #11: Setup Mongrel cluster for JRuby-on-Rails applications on Unix

10 Comments »

  1. Wow, Arun, when you answer questions, you *really* answer questions! Many thanks! Glen

    Comment by Glen — September 7, 2007 @ 4:20 pm

  2. Glad you liked it :)

    Comment by Arun Gupta — September 7, 2007 @ 5:11 pm

  3. Congratulations! I have another problem, when I run the IRB shell by Window->Other->Ruby Shell(IRB), its call the JRuby anyway. How can I change to ruby c-based?

    Comment by Paulo Canedo — September 13, 2007 @ 9:13 am

  4. Thanks for your help!

    Comment by Vitaliy — September 21, 2007 @ 6:25 am

  5. when i migrate the model database into the current version(right click on project->select migrate database->To current version) that time the following error will come how i can solve the problem please give me the solution

    Comment by Tamil — September 28, 2007 @ 8:58 pm

  6. When i migrate the model database into the current version(Right click on project->select migrate database->To current version) that time the following error has occured
    (in C:/Documents and Settings/tjothiramalingam/My Documents/NetBeansProjects/RailsApplication3)
    rake aborted!
    org.jvyamlb.ParserException: ParserException while scanning a block mapping we had this expected <block end>, but found org.jvyamlb.tokens.ScalarToken

    (See full trace by running task with –trace)
    Click here to re-run task with tracing enabled

    how i can solve the problem

    Comment by tamil — September 28, 2007 @ 9:05 pm

  7. Paulo, your question is answered at:

    http://ruby.netbeans.org/servlets/ReadMsg?list=users&msgNo=200

    Tamil, your question is answered at:

    http://ruby.netbeans.org/servlets/ReadMsg?list=users&msgNo=195

    Comment by Arun Gupta — October 2, 2007 @ 6:29 pm

  8. you cannot get more clear than that

    Comment by Forex — October 10, 2008 @ 7:38 am

  9. Congratulations! I have another problem, when I run the IRB shell by Window->Other->Ruby Shell(IRB), its call the JRuby anyway. How can I change to ruby c-based?

    Comment by BATTERY — November 26, 2008 @ 8:35 pm

  10. BATTERY, please post your question to .

    Comment by Arun Gupta — November 27, 2008 @ 8:39 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress