jruby – Installation and Hello World App

Background

Because of a side trek down the ElasticSearch road, specifically Logstash, wanted to develop a more congruent understanding of jruby.

Here we go.

jruby

per-requisite

Java JDK

Java JDK v1.8

Please download and ensure that Java’s JDK version 1.8 is downloaded and installed.

BTW, here is the link to Java JDK v1.8.

 

Artifact

jruby is available here.

Here is a current screen shot.

Image

 

Tabulate

Here is a quick break down:

Package OS Platform Packaging Installation
JRuby 9.2.0.0 Binary .tar.gz Linux Binary Unzip/Extract
JRuby 9.2.0.0 Binary .zip Windows Binary Unzip/Extract
JRuby 9.2.0.0 Windows Executable Windows Install4j Wizard  – x32 bit Run Installer
JRuby 9.2.0.0 Windows Executable (x64) Windows Install4j Wizard – x64 bit Run Installer
JRuby 9.2.0.0 Source .zip Multi-Platform Source Code Extract
JRuby 9.2.0.0 Complete .jar Multi-Platform Jar File Copy
JRuby-jars 9.2.0.0 .gem

 

Explanation

  1. Windows Executable
    • Most MS Windows users should go with the Windows Executable
    • Depending on OS bitness, please go with 32 or 64 bit
  2. Binary
    • Infrequent or Evaluation users should go with Binary Zip
  3. Source
    • Developers should go with the Source Code
  4. Complete Jar
    • OEM

 

Choice

We went the “Binary Zip” Route.

Download

Downloaded “jruby-dist-9.2.0.0-bin.zip

 

Extract

Using 7-Zip extracted the zip file.

Here is what our extracted folders look like.

 

Coding

Let us write a very simple script.

Hello World

Code

Ruby Source Code


# Beginner Ruby App
# https://en.wikibooks.org/wiki/Ruby_Programming/Hello_world
puts 'Hello, world!'

# Query Environment Variables
userDomain=ENV["USERDOMAIN"]
username=ENV["USERNAME"]

# Concatenate User Domain and Username
yourName=userDomain + '\\' + username

# Display Output
puts 'Your Full Username is ' + yourName



 

Invoke

Command File to initiate jruby script.


setlocal

REM SET JAVA_HOME to Version 1.8
set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181"
rem set "JAVA_HOME=C:\Program Files\Java\jdk-9.0.4"
rem set "JAVA_HOME=C:\Program Files\Java\jdk-10.0.2"

set "JRUBY_BIN=C:\Downloads\jruby\v9.2\zip\jruby-dist-9.2.0.0-bin\jruby-9.2.0.0\bin"

set "_app=helloWorld.rb"

%JRUBY_BIN%\jruby.bat "%_app%"

endlocal


 

Output

Here is the output of invoking the script.

One thought on “jruby – Installation and Hello World App

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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