The divas talk about the new and cool features of the NetBeans IDE
Insider Scoop From the Tutorial Divas
Archives
« February 2009 »
SunMonTueWedThuFriSat
1
2
4
5
6
7
8
10
11
13
14
15
16
17
20
21
22
23
24
25
26
27
28
       
       
Today
XML
Search



Recent Entries


Links

 


Today's Page Hits: 260

Tag Cloud: ajax creator dataprovider dropdown glassfish jasperreports javaone jmaki jruby jsc jsf netbeans photohunt rails ruby table vwp
« Previous month (Jan 2009) | Main | Next month (Mar 2009) »
Thursday Feb 19, 2009
Rails Generate Window Not Appearing With JDK 6u12

A few people have reported that when they right-click a Rails project node in the NetBeans IDE and choose Generate from the pop-up menu, nothing happens. One user reported that the problem is caused by an interaction with the Java Development Kit (JDK) 6u12. To fix this problem, download a different version of the JDK, such as 6u11, and point the IDE to that installation. See my previous blog for instructions on how to use a different JDK.

Posted at 06:43PM Feb 19, 2009 in Ruby  |  http://blogs.sun.com/divas/entry/rails_generate_window_not_appearing  |  Permalink  |  Comments[1]
del.icio.us | furl | simpy | slashdot | technorati | digg

Wednesday Feb 18, 2009
Using Gems With JRuby

If you are new to JRuby, you might not know that you cannot use a gem that has native extensions with JRuby, unless that gem builds its library in a platform-neutral manner. When you use the JRuby gem executable to try to add such a gem to your repository, you will get a message like this.

Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

C:/jruby/jruby-1.1.5/bin/jruby.bat extconf.rb install rmagick --no-rdoc --no-ri
C:/jruby/jruby-1.1.5/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (NotImplementedError)
    from C:/jruby/jruby-1.1.5/lib/ruby/1.8/mkmf.rb:1:in `require'
    from extconf.rb:1
Gem files will remain installed in C:/rubyrepos/jrubygemrepo/gems/rmagick-2.9.1 for inspection.
Results logged to C:/rubyrepos/jrubygemrepo/gems/rmagick-2.9.1/ext/RMagick/gem_make.out

As you would guess, you then need to hunt for an equivalent gem that will work with JRuby. Anything with "pure Ruby" in its description is a good bet. In the case of RMagick, there is a RMagick4j. Some other examples JRuby compatible gems are Mongrel, Hpricot, ImageVoodoo, JRuby-OpenSSL, JRuby/LDap, json_pure, and postgres_pr.

If you are developing with both Ruby and JRuby, you might want to create a separate repository that holds the gems that work for both implementations, and then put that repository into your GEM_PATH. That way, you won't have to install the gem twice. If you are using NetBeans IDE, use the Ruby Platform Manager to add the repository to a platform's GEM_PATH.

If you want to require a certain gem based on whether you are running on JRuby, you can check whether JRUBY_VERSION is defined.

Posted at 04:07PM Feb 18, 2009 in Ruby  |  http://blogs.sun.com/divas/entry/using_gems_with_jruby  |  Permalink  | 

Thursday Feb 12, 2009
Telling NetBeans IDE Which JDK to Use

A customer has filed a bug about the Generator menu item not working for NetBeans Rails projects if the IDE is using version 6u12 of the Java Development Kit (JDK) software.

Not knowing how to tell the IDE to use a different JDK, the user reinstalled the NetBeans software.

If you don't know already, there is no need to go to such lengths. Here are two ways to tell the IDE which JDK to use.

Posted at 05:12PM Feb 12, 2009 in Ruby  |  http://blogs.sun.com/divas/entry/telling_netbeans_ide_which_jdk  |  Permalink  | 

Monday Feb 09, 2009
Installing Your Own JRuby to Use With the NetBeans IDE

The Ruby support for NetBeans includes a bundled JRuby installation. This is great for quickly getting started with the IDE, but I recommend that you download and install your own version of JRuby and use that one instead. There are a few reasons for doing so, one of which is that the next time you install a NetBeans version, you will get a new bundled JRuby installation, most likely a different version. If you have added gems to the old bundled JRuby, you will have to reinstall those gems to the new bundled JRuby.

Another reason is when you want to work with more recent JRuby version. For this reason alone, it is good to learn how to install JRuby and register it with the IDE. Below are the steps that I do to add a JRuby installation.

  1. First download JRuby from the JRuby site and install it by following the Getting Started instructions.

    TIP: If you are downloading the 6RC1 version, after you unpack it, rename the directory from jruby-1.1.6RC1 to jruby-1.1.6. For some reason, The GlassFish app server barfs on the RC1 in the path name.

  2. Put JRuby's bin in your environment path. I remember reading some recommendation that if you have both Ruby and JRuby, put JRuby after Ruby in the path. Because I switch out JRuby versions often, I created a JRUBY environment variable that points to the bin directory of the JRuby that I am working with, and I added the JRUBY environment variable to my path. To test it, I type jruby -v on the command line.

  3. Now you can register your new JRuby installation with the NetBeans IDE. Choose Tools > Ruby Platforms from the main menu. Choose Add Platform, and navigate to and select the JRuby executable in the bin directory. If you are on Windows, this is jruby.bat. Click Open.

  4. This step is optional, and I don't suggest it if you are new to Ruby and installing gems. I get tired of having to install the same gems over and over every time I upgrade JRuby, so I create a separate repository (outside of the installation folder) for the gems. If you want to do this, click the Browse button to the right of the Gem Home text box, type the path to your gem repository, and click Open. (If you don't have one yet, use the New Folder button in the dialog box to create it, such as some-ruby-repo-path/jrubygemrepo. When you click Open, it will ask if you want to set up your repository there, click OK.)

    Next click the Add button to the right of the Gem Path text box and add the repository to the gem path.

  5. You will need the debugger gems. Follow the instructions on the NetBeans Ruby Debugger wiki page. Make sure you get the correct versions -- the ones noted on the wiki page. If you opted for a separate gems repository in the previous step, then add --install-dir your-repo-path to the gem install commands.

  6. Next, I install Rails. You can do this from the command line, or from the IDE's Ruby Gems Manager, which is available from the main menu. When you open the Ruby Gems manager, click the Settings tab and select Fetch All Versions so that you have a choice of which version to download. Then click the New Gems tab and click Reload Gems. Select Rails and click Install. You will be asked to select a version. If you want to follow the 6.5 tutorials, be sure to install Rails 2.1.2 or 2.1.0 because you need Rails 2.1.* for the tutorials. Version 2.1.1 is not compatible with JRuby.

  7. Some other gems you might want to install right away are jruby-openssl, Active Record JDBC Adapter, and the JDBC adapters for the databases that you use. See Using Database Servers With JRuby for more information about the JDBC adapters.

Hopefully, this is complete enough to get you going. Please add comments if you have suggestions or steps to add.

Posted at 06:13PM Feb 09, 2009 in Ruby  |  http://blogs.sun.com/divas/entry/installing_your_own_jruby_to  |  Permalink  | 

Tuesday Feb 03, 2009
no such file to load -- mysql

Rails never fails me. As soon as I publish a series of tutorials for a NetBeans release, a new Rails release comes out which breaks my tutorials (and, apparently, most everyone else's). Gratefully, some customers took the time to click the Feedback button at the end of our tutorials to let us know the tutorials were no longer working. One customer wrote:

"When trying to create the database following the steps indicated, I got an error indicating the mysql gem had been removed from Rails 2.2.2 and that I should install the mysql gem. (Note from me: the actual error message is "The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.") However, that gem is also native and can't be installed with JRuby (the misleading directive to do so from NetBeans was really annoying)."

I have to agree that this is indeed REALLY annoying. However, the "misleading directive" comes from Rails, and not from NetBeans. And, since Rails 2.2 came out after NetBeans 6.5, this was an unexpected message.

While the directive may be true for Ruby, it is not true for JRuby, because the the MySQL adapter is included with JRuby. In addition, as the user pointed out, you can't install the mysql gem with JRuby because you cannot use any gems that build native C libraries during the install process, and that includes the mysql gem.

I did some googling and found two solutions:

If anyone else has any other solutions, please post a comment.

P.S. For all you Ruby programmers, when you try out a tutorial, you really should pay attention to what gem versions the tutorial was written for. Gem releases such as Rails and RSpec are not always backwards compatible, so there is a chance that the tutorial will not work with releases that came out after the tutorial was written.

Posted at 01:56PM Feb 03, 2009 in Ruby  |  http://blogs.sun.com/divas/entry/no_such_file_to_load  |  Permalink  |