Oracle GlassFish Server 3.0.1 Scripting Framework Guide

Installing JRuby and Rails

    Installing JRuby and Rails on GlassFish Server comprises three general steps:

  1. Download and install GlassFish Server.

  2. Download and install JRuby.

  3. Install Rails on top of your JRuby installation.

The instructions in this guide assume that GlassFish Server software is already installed and running. If GlassFish Server is not already installed, refer to the Oracle GlassFish Server 3.0.1 Installation Guide for installation instructions.

JRuby and Rails can be installed on GlassFish Server in either of two ways:

The remainder of this section explains how to install JRuby and Rails using these two different installation methods.

ProcedureTo Install JRuby and Rails Using Update Tool

This procedure explains how to install JRuby and JRuby Gems (including Rails) directly on top of an existing GlassFish Server installation using the GUI-based Update Tool.

Before You Begin

GlassFish Server must be installed and running before proceeding with these instructions.

In these instructions, the root GlassFish Server installation directory is referred to as as-install.

  1. In a command shell for your operating system, change to the as-install/bin directory and run the updatetool command.


    Tip –

    If you are running Update Tool from behind a firewall that implements a proxy server, you may need to set the HTTP_PROXY environment variable before running the updatetool command. For example, in a Solaris/Linux Bash shell:


    export HTTP_PROXY=http://proxy-server:port
    

    If this is the first time you have launched updatetool, the full Update Tool product will not yet be installed, and you are prompted to allow installation to proceed.

    1. Type y when prompted to install Update Tool.

      The installer downloads and installs the full Update Tool product and then exits.

    2. Type the updatetool command again to launch Update Tool.

    The Update Tool main window is displayed, with Available Updates highlighted.

  2. Select the JRuby on GlassFish and JRuby Gems packages from the list of Available Add-Ons, and then click Install to install the packages.

    The contents of the JRuby on GlassFish and JRuby Gems packages are as follows:

    • JRuby on GlassFish – Contains JRuby 1.3.1

    • JRuby Gems – Contains Rails 2.3.2, Warbler, jdbc-mysql, and activerecord-jdbcmysql-adapter packages.

  3. Set the JRUBY_HOME environment variable to the location of your JRuby installation.

    By default, when installed using Update Tool, JRuby is installed in a subdirectory below as-install/glassfish. The commands to set JRUBY_HOME will typically be as follows:

    • Solaris/Linux:


      export JRUBY_HOME=as-install/glassfish/jruby
      
    • Windows:


      set JRUBY_HOME=C:\as-install\glassfish\jruby
      
  4. Add the JRUBY_HOME/bin directory to your system path.

    For example:

    • Solaris/Linux:


      export PATH=$PATH:$JRUBY_HOME/bin
      
    • Windows:


      set PATH=%JRUBY_HOME%\bin;%PATH%
      
  5. Proceed with the JRuby container configuration instructions in Configuring JRuby for GlassFish Server.

ProcedureTo Install JRuby in Standalone Mode

This procedure explains how to download and install JRuby and then configure it to work with GlassFish Server. If you prefer to use the GlassFish Server Update Tool to install JRuby directly on GlassFish Server, use the procedure in To Install JRuby and Rails Using Update Tool instead.

  1. Download the desired JRuby package from the JRuby Downloads page and save it in the location of your choice.

    Packages are available in a variety of formats, including tar.gz, ZIP, Windows executable, and JAR.

  2. Unpack the JRuby package in the directory of your choice.

    For the purposes of this procedure, the directory in which you unpack the JRuby package is referred to as jruby-install.

  3. Set the JRUBY_HOME environment variable to the location of your JRuby installation.

    For example:


    export JRUBY_HOME=jruby-install
    
  4. Add JRUBY_HOME/bin directory to your system path.

    For example:


    export PATH=$PATH:$JRUBY_HOME/bin
    
  5. Perform the following additional steps to configure the JRuby installation to work with GlassFish Server.

    1. Change to the GlassFish Server bin directory and start the GlassFish Server domain.

      For example:


      cd as-install/glassfish/bin
      ./asadmin start-domain domain-name
      
    2. Specify the JRuby home directory:


      ./asadmin configure-jruby-container --jruby-home=jruby-install
      
  6. Install the required Rails Gems for standalone JRuby operation.


    jruby -S gem install rails
    

    The -S parameter tells JRuby to look for the install rails script anywhere in the JRUBY_HOME path.