You will probably need to install all this as root.
Prerequisites
The first thing you need is Java. You need the Java JRE and JDK (at least version 1.4 according to this http://svn.codehaus.org/jruby/trunk/jruby/README). I'm not going to go through the details so Ill just point you towards some tutorials
https://jdk-distros.dev.java.net/ubuntu.html - the easy way
http://java.sun.com/javase/downloads/index.jsp - the less easy way
To verify you have Java, just check the version. You should get something like this:
# java -versionNext thing to install is Ant, its a prerequisite for building JRuby.
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
# apt-get install antVerify you have ant:
# ant -versionBuilding JRuby
Apache Ant version 1.6.5 compiled on July 5 2006
If you have Subversion you can just go
# svn co http://svn.codehaus.org/jruby/trunk/jrubyIf you dont have Subversion you can download it here: http://dist.codehaus.org/jruby/ and extract it using:
# tar -xzvf jruby-src-LATEST.VERSION.tar.gz(At this point it might be a good idea to move the jruby folder to somewhere like /usr/local/lib just to make it more globally available and less specific to any particular user. This location, where ever you decide, will be called JRUBY_HOME)
Then:
# cd ./jrubyYou should get output like this:
# ant clean jar
Buildfile: build.xmlIf you didn't get a Build Successful, you've got problems, loser! Woah, thats probably a bit harsh. But seriously, you're on your own.
init:
clean:
[delete] Deleting directory /usr/local/lib/jruby/build
[delete] Deleting 2 files from /usr/local/lib/jruby/lib
[delete] Deleting directory /usr/local/lib/jruby/docs/api
init:
prepare:
[mkdir] Created dir: /usr/local/lib/jruby/build
[mkdir] Created dir: /usr/local/lib/jruby/build/classes
[mkdir] Created dir: /usr/local/lib/jruby/build/classes/jruby
blahblahblabh java ant creation stuff filler text blahblahblah
jar-jruby:
[jar] Building jar: /usr/local/lib/jruby/lib/jruby.jar
jar-openssl:
[jar] Building jar: /usr/local/lib/jruby/lib/jruby-openssl.jar
jar:
BUILD SUCCESSFUL
Total time: 11 seconds
Ok, great you've built JRuby but you can't run it from the commandline yet!
Add JRuby to the path
# jruby
bash: jruby: command not found
Duh-oh! You need to add jruby to your path. I'm going to assume you use Bash, but it should be similar enough for whatever shell you use.
# vi ~your_username/.bashrc
Add this:
to the end of the file.
JRUBY_HOME=/usr/local/lib/jruby # or where ever you put it.
PATH=$PATH:$JRUBY_HOME/bin
Now reload your bash profile
# source ~yourusername/.bashrc
(Note to add JRUBY_HOME to the global path, add
JRUBY_HOME=/usr/local/lib/jruby # or where ever you put it.to /root/.profile and (/root/.bash_profile or /root/.bashrc)
PATH=$PATH:$JRUBY_HOME/bin
http://www.troubleshooters.com/linux/prepostpath.htm )
Now try this:
# jruby -vAs Millhouse says: Radical!
ruby 1.8.5 (0) [java]
Well thats about it. JRuby is now installed and you can use it as a ruby interpreter in the same way that you would use the official ruby interpreter.
# jirb
irb(main):002:0> puts "moo!"
moo!
=> nil
irb(main):003:0>
11 comments:
hey thanks, this was helpful for me!
Clear and concise. Installed on RedHat EL4.
Thanks.
Thank you for your information.
THANK YOU VERY MUCH!!!!! The tutorial worked like a charm.
Radical !
Ubuntu server, I'm total newbie for all of that and this helped me 2 times. Thanks!
worked fine on ubuntu studio 8.10
Thanks a lot!!!
Worked on ubuntu 8.10
this tutorial works under 9.04 too. If, after installing ant and typing:
ant -version
you get "Unable to locate tools.jar" you can follow this: http://marc.info/?l=ant-user&m=121520341302219&w=2 . It helped me solving the problem.
You might want to update this now that the jRuby project has moved to git... :)
Great manual
Thanks
Post a Comment