RVM, JRuby setting specific java environment - jruby

Ubuntu 10.04LTS
Netbeans 6.9.1 (with embedded JRuby 1.5.1)
JDK6u17 (installed in /opt)
GlassFish Gem 1.0.2
I am using a old JDK because of this bug: http://jira.codehaus.org/browse/JRUBY-4785
I want to install RVM and install another instance of JRuby. But i cant find any information how to set JRuby Java environment to JDK6u17(directory /opt).
I would be grateful for the help.

JRuby on default use system Java. So if i change "system" Java, JRuby will use that one.
I have figured two ways to set specific Java environment.
Set JAVA_HOME.
Here is a good one tutorial:
http://vietpad.sourceforge.net/javaonlinux.html
Update java setting from terminal(works only for JVM installed from apt-get or aptitude).
sudo update-alternatives --config java

That JRuby bug is marked as fixed for JRuby 1.6RC1, so you no longer need to use the old JDK.
I am using RVM and JRuby 1.6RC1 on Ubuntu 10.04 LTS just fine. There are instructions on my website for working with this version of Ubuntu, RVM and JRuby.
You don't need all the instructions, but some of the commands might help, if you get stuck.
http://www.scottlowe.eu/deploying-rails-3-with-jruby-daemonized-glass
(It does tell you how to get a modern JDK installed)

Related

Is using -S with JRuby recommended even when using a Ruby version manager?

Based on this page on the JRuby wiki and other resources I see the recommendation is
to always use jruby -S.
because
The -S parameter tells JRuby to use its version of the installed binary, as opposed to some other version (such as an MRI version) that might be on your PATH.
Using rbenv and rvm I've had issues when using -S with JRuby (see this question) and my understanding is that both those version managers solve the problem -S attempts to address.
You do not need to run the gem command with jruby -S gem if you are using a Ruby manager such as rbenv or rvm. Those tools manage your command path for you so that the correct Ruby runtime and the correct version of rubygems are used. Similar applies to the rake.

how can i install jruby alongside ruby

i first installed jruby using the sudo apt-get install jruby command, which succeeded but it did gave me 1.5.6 version when i wanted a later version. So i uninstalled it and used rvm install jruby command and i was able to install jruby version 1.7.19 but after installing it, my ruby applications,which were funtioning right started producing errors complaining of missing gems like mysql2 gem missing,run bundle install. i run bundle install but nothing i did seemed to help, i was getting nowhere.
When i asked for the ruby version, i was receiving the jruby version instead, its lyk jruby over shadowing ruby,,,, So i decided to uninstall jruby, reinstall ruby and now ruby is functioning as well as before.
Can anyone help me with the ubuntu commands which can help me install jruby alongside ruby, so that both work well without any errors???
Am requesting for serious help please
I usually prefer rbenv over rvm for running multiple versions of Ruby on the same machine. Here is sample install/usage steps:
Install rbenv git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
Install ruby-build git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Modify your .bashrc echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Restart your shell
Install rubies. e.g. rbenv install jruby-1.7.20
Rehash (create new rbenv shims. You'll need to run this anytime you install a gem that adds a command) rbenv rehash
You can list the Ruby versions available to install with rbenv install -l
You can set the default global ruby version with rbenv global jruby-1.7.20.
You can also pass "system" instead of an installed Ruby if you want the default to be the OS installed version of Ruby.
You can change Ruby version on the fly with rbenv shell 1.9.3-p551
See here (https://github.com/sstephenson/rbenv#command-reference) for a lot more detail and documentation.
Edit: I was assuming you're using Ubuntu, hence the edit of .bashrc. If you're using another OS you may need to change that to .bash_profile
Thanks for that answer. I have also found out that it is soo possible to have jruby and ruby installed concurrently using rvm. After installing the various versions or languages say ruby and jruby, only the default language and version is running in the terminal as current so you have to run the command 'rvm list' to show you the various installed versions after which you run 'rvm use language-X.X.XX' say rvm use jruby-1.7.20.1 to make jruby-1.7.20.1 run as the current in that terminal.
You can also run another version in a different terminal concurrently but please note, you have to run the command rvm use every time you open up a new terminal, else you make that version default.

Is Installing Jruby on Nitrious.io possible?

Does Nitrous.io support JRuby?
Installing it with RVM seems to attempt to run a sudo apt-get update, which it won't allow...
Thanks.
First you will need to update RVM.
rvm get head
From there you can install jruby:
rvm install jruby
Next, set RVM to use jruby.
rvm use jruby
Next, add jruby to your PATH.
export PATH=$PATH:/opt/jruby/bin
From there you should be able to check that jruby is working with the following command:
jruby --version
So, installing a jruby binary seems to work fine, but still cant figure out how to get RVM to do the install...
So, I just manually moved jruby into the .rvm folder...I put a copy of the binary in the .rvm/rubies directory, made a symlink from the binaries' "jruby" executable to a "ruby" executable in the .rvm/rubies bin folder, made related empty folders for jruby in the .rvm/gems directory for the version of jruby, and did "rvm jruby-1.7.8 do rvm gemset create" and now I can do "rvm use jruby"...things seem to work fine.
I have a bad feeling about this tho. But I always do when using RVM...
I don't know if it will actually require any additional packages (so this might not work), but you could try running rvm with --autolibs=0 so it doesn't attempt to install any packages; see https://rvm.io/rvm/autolibs for details.

CommandT causing macvim to segv

Using ruby 2.0.0. mvim is built with ruby support enabled. Use the .vba approach to install the plugin. Now whenever I launch mvim it SEGVs. If I remove the CommandT plugin all is back to normal.
THe architecture flag is -arch x86_64 so I didn't override the arch flag to 32 bit when running make in the ./ruby/command-t directory.
Also tried to uninstall and install mvim but no luck.
Any ideas?
After some more googling found the link: http://arjanvandergaag.nl/blog/compiling-vim-with-ruby-support.html. So yes, vim and CommandT were compiled with different versions of ruby support.
Did the following:
brew edit macvim
Updated --with-ruby-command to point to rvm ruby path which CommandT was using.
brew uninstall macvim
brew install macvim
The original Formula had --with-ruby-command set to ${RUBY_PATH}. So my solution is a little hacky. What's the right way to get brew to follow rvm default ruby path?

RVM won't install JRuby, gets exception

So, I have rvm installed on my machine, and I type:
rvm install jruby
Everything looks good at first, but eventually I get:
jruby-1.5.6 - #fetching
jruby-1.5.6 - #extracted to /home/jenny/.rvm/src/jruby-1.5.6 (already extracted)
Building Nailgun
jruby-1.5.6 - #installing to /home/jenny/.rvm/rubies/jruby-1.5.6
jruby-1.5.6 - #importing default gemsets (/home/jenny/.rvm/gemsets/)
Copying across included gems
Exception in thread "main" java.lang.NoClassDefFoundError: org.jruby.Main
at gnu.java.lang.MainThread.run(libgcj.so.9)
Caused by: java.lang.ClassNotFoundException: org.jruby.Main not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.9)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at gnu.java.lang.MainThread.run(libgcj.so.9)
jenny#linux-auvv:~/workspace/pcms_stable>
I have absolutly no context for debugging this... I honestly have no idea what to do...
I'm on OpenSuse, and when I type "java -version", I get:
java version "1.6.0_0"
OpenJDK Runtime Environment (build 1.6.0_0-b11)
OpenJDK Server VM (build 1.6.0_0-b11, mixed mode)
I can't see any references to java requirements for JRuby, though...
As far as RVM, I'm running:
rvm 1.2.4 by Wayne E. Seguin (wayneeseguin#gmail.com) [http://rvm.beginrescueend.com/]
I can install other rubies with RVM (1.9.2, 1.8.7, that sort of thing) with no problem, this is the first issue I've ever found.
It doesn't seem to matter WHICH jruby I install, either. My rvm knows about:
# JRuby
jruby-1.2.0
jruby-1.3.1
jruby-1.4.0
jruby[-1.5.6]
jruby-head
I don't even get the same errors for each one of them:
For 1.2.0, 1.3.1, 1.4.0 I get:
Fatal: GCJ (GNU Compiler for Java) is not supported by JRuby.
Where 1.5.6 and head get me the error I mentioned first.
I WANT to use JRuby with Rails 3, so I'm figuring I want the newest version I can get (which is having the exceptions)
Is there ANYTHING I can do, or am I just doomed to not be able to use RVM for my purposes?
EDIT:
I have confirmed that it's not just RVM, it is JRuby that is to blame. To test, I downloaded JRuby without rvm at all, through the website (I chose version 1.6). I unpacked it as per the instructions, and typed:
bin/jruby -v
in the extracted directory.
I got the exact same error:
jenny#linux-auvv:~/jruby-1.6.0.RC1> bin/jruby -v
Exception in thread "main" java.lang.NoClassDefFoundError: org.jruby.Main
at gnu.java.lang.MainThread.run(libgcj.so.9)
Caused by: java.lang.ClassNotFoundException: org.jruby.Main not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.9)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at gnu.java.lang.MainThread.run(libgcj.so.9)
So, still have no clue what's going on, but at least I know now it's a jruby issue, and not an rvm one (though I still WANT it installed through rvm)
Edit:
So, I tried updating my OpenJDK, and it was no dice, but I found ANOTHER version of OpenJDK (that I didn't have installed) through YAST, and installed THAT one, and suddenly my manually installed jruby works just fine:
jenny#linux-auvv:~/jruby-1.6.0.RC1> bin/jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (OpenJDK Client VM 1.6.0_0) [linux-i386-java]
When I type java -version, I even get something different:
jenny#linux-auvv:~/jruby-1.6.0.RC1> java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.6.2) (suse-0.1.1-i386)
OpenJDK Server VM (build 14.0-b16, mixed mode)
It even works in RVM, so hooray!
I would try installing the Sun JRE/JDK.
Or perhaps you could reinstall OpenJDK(probably the easiest way to reset it to being the default on your system).
Update:
To change the default java do this. First check which Javas are available:
update-alternatives --list java
To actually change which one you are using do this:
update-alternatives --config java
I think the clue is in this:
Fatal: GCJ (GNU Compiler for Java) is not supported by JRuby.
For whatever reason, your system is configured to fire up GCJ instead of your OpenJDK compiler. Check the docs on your system for how it handles the case where multiple things can provide the same service name (multiple versions of compilers, for example, or multiple interpreters) and see what you can do to have OpenJDK be the default handler for Java compilation and execution.