Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a short list of steps to get the <a href="http://rubygems.org/gems/hello-world" rel="nofollow noreferrer"><code>hello-world</code> gem</a> running using JRuby and Clojure and a few references. In fact, the steps compose just a short sketch of how the material from the references might come together (with some <code>project.clj</code> entries). The first reference, <a href="http://yokolet.blogspot.com/2011/09/haml-on-clojure-web-app.html" rel="nofollow noreferrer">Haml on Clojure Web App</a> on Yoko Harada's (@yokolet's) blog, uses a slightly different way actually to call into JRuby, but includes the key remark on how to write <code>require("...")</code> lines for use with JRuby and gems on the classpath.</p> <ol> <li><p>Add <code>[org.jruby/jruby-complete "1.6.7.2"]</code> to your <code>:dependencies</code> and have Leiningen fetch the dependencies.</p></li> <li><p>Create a <code>gems</code> directory in the project root and add it to <code>:resource-paths</code> in your <code>project.clj</code> This requires Leiningen 2. See the <a href="https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L254" rel="nofollow noreferrer">Leiningen source</a> for the correct format.</p></li> <li><p>Say</p> <pre><code># see reference 4 GEM_HOME=gems GEM_PATH=gems java -jar ~/.m2/repository/org/jruby/jruby-complete/1.6.7.2/jruby-complete-1.6.7.2.jar -S gem install hello-world </code></pre> <p>in the project root.</p></li> <li><p>Start up the REPL service of your choice with <code>GEM_HOME</code> and <code>GEM_PATH</code> set as above. (I tested this with <code>lein2 swank</code>.)</p></li> <li><p>Say the following at the REPL:</p> <pre><code>;;; see reference 2, first snippet (let [runtime (JavaEmbedUtils/initialize (list)) evaler (JavaEmbedUtils/newRuntimeAdapter)] (doseq [ruby-expr ["require('rubygems')" "require('gems/hello-world-1.2.0/lib/hello-world')"]] (.eval evaler runtime ruby-expr))) </code></pre></li> <li><p>Behold the <code>nil</code> return value, as well as a couple of lines printed out to the terminal the REPL service has been started from.</p></li> </ol> <p>References:</p> <ol> <li><a href="http://yokolet.blogspot.com/2011/09/haml-on-clojure-web-app.html" rel="nofollow noreferrer">Haml on Clojure Web App</a> on Yoko Harada's (@yokolet's) blog</li> <li><a href="http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar" rel="nofollow noreferrer">JRuby 1.1.6: Gems-in-a-jar</a> on Nick Sieger's blog</li> <li><a href="http://kenai.com/projects/jruby/pages/DirectJRubyEmbedding" rel="nofollow noreferrer">DirectJRubyEmbedding</a> on the JRuby Wiki at Project Kenai</li> <li><a href="https://stackoverflow.com/questions/8734279/consuming-gems-from-jruby-complete">consuming gems from jruby-complete</a> here on SO (note the comments)</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload