Skip to main content

Setting JRuby to run in 1.9.2 mode by default

JRuby comes with both 1.8.7 and 1.9.2 (currently) and the default is 1.8.7. If you want to change it you have to feed an option at the command line:

$jruby --1.9

This weekend I had to migrate a rails program that I hadn't written and the author used 1.9.2 notation so it would not run on JRuby with the default settings. So I had to add the version option with every command which gets old quick. I looked online for a way to make this automatic (and on my JRuby books) but could only found the way to do it on a Mac or Linux but all Windows references just mentioned nebulous concepts such as environmental variables and seemed to be different from which version of Windows you are using. Here is how to do it.

Windows 7:

Got to Control Panel, System.












Wine (Crossover 10):

Java 6 version 21 will run on Wine (at least on Crossover 10) and you can install JRuby on top of that. To set environmental variables you have to go to regedit and set it there manually. Follow the screen-shots below.

Find the HKEY_CURRENT_USER option on the side bar, hit the plus sign and select "Environment" from the sub-options. Set the Key to JRUBY_OPTS (don't forget the s) and the value to --1.9 (two dashes). Then go to the right pane, right click on a white space and select "New - String Value" to create a new key. Right click on the area shown in the screen-shot. Then add a New string key with the name JRUBY_OPTS and the value --1.9 per the screen-shot.






Mac OS X and Linux:

The Mac and Linux uses a command line to set the environmental variable so it can be done with one command.

$export JRUBY_OPTS=--1.9



 

This command will set the version for the session, to make it permanent add it to your .bashrc file in your home directory.




On the mac you look for the .bash_profile file in your home directory and add the same line to it.

Comments

  1. Thanks for posting, this was pretty useful.

    ReplyDelete
  2. Thanks David. This post has helped me to run Jruby in 2.0 mode on Windows.

    ReplyDelete

Post a Comment

Popular posts from this blog

What Medieval Economics can teach us about tariffs.

As a teen, I used to play Dungeons and Dragons (D&D) with my friends. This started an interest in the medieval period that led to me taking a medieval history class in college just to understand the period more. Over the years I've also read great books like " Dungeon, Fire and Sword " about the crusades (I recommend the book) and yet with all that knowledge it wasn't until recently that it occurred to me I had a completely wrong understanding of economics in the Medieval Period. "Viking helmets, sword and footwear" by eltpics is licensed under CC BY-NC 2.0 In my D&D games, players who are adventures battling monsters and creatures would need equipment and on the trips to town, they'd get resupplied with their adventuring necessities. I'd run these moments referencing my imagination of what it must have been and fantasy books I'd read. There be an inn with a raucous bar, a gruffly black-smith, if a city also a weapon and armor sm...

Testing with Cucumber, Sinatra and Capybara

Everything you need to know There are many elements you need to simultaneously learn to do effective testing of your code. Because some of these elements are very simple a lot of explanations just jump over what you need to know and give them up as obvious. Let’s start with a list of the things you need to learn: Gherkin (the language of Cucumber) ——> super easy Capybara (the DSL that controls the browser tests) Rspec (the DSL in which the actual pass/fail tests are written.) None of these are hard. But having to learn all at the same time can seem daunting. But it’s not! It’s easy peasy but takes time. :-/ It took me three days to get a handle on this. And I hope by reading this you’ll get a handle on it much much quicker. Let’s start with Cucumber first. Cucumber Five things you need to know about Cucumber: Cucumber tests are located on a features folder that have plain text files with a .feature extension and written in Gherkin . The .feature files contain t...

Best Tech Books

Best Tech Books for Programming Language Learning I'm a bit of a polyglot no only in human languages (English, Spanish, Japanese) but also with programming languages. I found that the best way to get a deep understanding of the programming field, I needed to be broad. I got introduced to Bruce Tate's 7 languages in 7 weeks series right when I was starting to learn Ruby and found the cross-language trends to be very useful in knowing what to learn for the future.  So here is a list of Programming Books that I found good for learning a language. These are the must have books in my opinion to "get" or "grok" the language. Most of these books I have not finished but they're so good I can recommend them for other language learners and polyglots. All these books should accelerate your learning dramatically.  Poignant Guide to Ruby Ruby: POODR and _why's Poignant Guide to Ruby .  Okay, so _why's Poignant Guide to Ruby is the reason I fell in love with ...