Miles to go ...

Arun Gupta is a Technology Evangelist for Web Services and Web 2.0 Apps at Sun. He was the spec lead for APIs in the Java platform, committer in multiple Open Source projects, participated in standard bodies and contributed to Java EE and SE releases.
« JRuby on Rails,... | Main | The Rich Web Experie... »

http://blogs.sun.com/arungupta/date/20070907 Friday September 07, 2007

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

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

del.icio.us | furl | simpy | slashdot | technorati | digg
Comments:

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

Posted by Glen on September 07, 2007 at 04:20 PM PDT #

Glad you liked it :)

Posted by Arun Gupta on September 07, 2007 at 05:11 PM PDT #

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?

Posted by Paulo Canedo on September 13, 2007 at 09:13 AM PDT #

Thanks for your help!

Posted by Vitaliy on September 21, 2007 at 06:25 AM PDT #

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

Posted by Tamil on September 28, 2007 at 08:58 PM PDT #

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

Posted by tamil on September 28, 2007 at 09:05 PM PDT #

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

Posted by Arun Gupta on October 02, 2007 at 06:29 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
« JRuby on Rails,... | Main | The Rich Web Experie... »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.

--> ajax ajaxworld conf eclipse fitness gem glassfish glassfishday hyderabad india indigo interoperability javaone javaone2008 jax-ws jmaki jpa jruby mac marathon metro microsoft mysql netbeans phobos photography presos railsconf ruby rubyonrails running runninglog runsfm screencast siliconvalleymarathon sun suntechdays swdp tango theserverside totd training traveltips v3 vista wcf web2.0 webservices webtier windows wsaddressing wsit youtube
Locations of visitors to this page

calendar

« September 2008
SunMonTueWedThuFriSat
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today
www.flickr.com
This is a Flickr badge showing public photos from ArunGupta. Make your own badge here.
Add to Technorati Favorites

Last 50