Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8439287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:58:09+00:00 2026-06-10T07:58:09+00:00

I am a fairly simple need to use a Ruby class from within Clojure.

  • 0

I am a fairly simple need to use a Ruby class from within Clojure. The complicating factors are that the class is supplied in a gem. The optimal approach would be to setup my Leiningein project file along the lines of:

(project foo ""
  ...
  :dependencies [[clojure ...]
                 [jruby ...  ]])

Likewise I would prefer to simply check the gem and its dependencies into the local repo directory. Therefore, from my ideal usage would then be:

(ns bar.baz
  (require [jruby.something :as jruby])

(def obj (jruby/CreateAnInstance "TheGemClass"))

(def result (jruby/CallAMethod obj "method_name" some args))

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:58:11+00:00Added an answer on June 10, 2026 at 7:58 am

    Here’s a short list of steps to get the hello-world gem 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 project.clj entries). The first reference, Haml on Clojure Web App 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 require("...") lines for use with JRuby and gems on the classpath.

    1. Add [org.jruby/jruby-complete "1.6.7.2"] to your :dependencies and have Leiningen fetch the dependencies.

    2. Create a gems directory in the project root and add it to :resource-paths in your project.clj This requires Leiningen 2. See the Leiningen source for the correct format.

    3. Say

      # 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
      

      in the project root.

    4. Start up the REPL service of your choice with GEM_HOME and GEM_PATH set as above. (I tested this with lein2 swank.)

    5. Say the following at the REPL:

      ;;; 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)))
      
    6. Behold the nil return value, as well as a couple of lines printed out to the terminal the REPL service has been started from.

    References:

    1. Haml on Clojure Web App on Yoko Harada’s (@yokolet’s) blog
    2. JRuby 1.1.6: Gems-in-a-jar on Nick Sieger’s blog
    3. DirectJRubyEmbedding on the JRuby Wiki at Project Kenai
    4. consuming gems from jruby-complete here on SO (note the comments)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fairly simple question: I have an init method on my class that has the
I need a fairly simple format to use as metadata (title, creator, description, and
So, I recently took a job where I need to develop a fairly simple
I've got a fairly simple loop that supposed to run through all elements in
I have a fairly simple requirement for a query API which I need to
I have a fairly simple android app, it gets protobuf data from a web
My problem is fairly simple. I have table sets that store product sets (more
I'm trying to write a fairly simple application that passes data between two sockets.
I have a need to do some fairly simple (at least on the surface)
I work on a fairly simple but large two-tier application that consists approximately 40

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.