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 8412333
In Process

The Archive Base Latest Questions

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

Sometimes you want to glue solutions writen in different JVM languages. To do so

  • 0

Sometimes you want to glue solutions writen in different JVM languages. To do so you need to call that languages or somehow use java bitecodes. What is purest, safest, nicest way to do so in Clojure?

For example what is best way to call Scala from Clojure?

(I know that other way is easy. You can generate .class by gen-class as it writen in Can you mix the JVM languages? ie: Groovy & Clojure, but that just allow you to use clojure from other languages.)

  • 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-10T00:38:59+00:00Added an answer on June 10, 2026 at 12:38 am

    Since Clojure runs on the JVM, you can access any known class which is on your classpath out of Clojure. Here is a Scala example. To make the classpath setup and dependency management easier, use Leiningen to generate a project.

    lein new clojure-scala
    

    In the project folder, modify the project.clj and add a dependency for Scala’s language libraries, and the scala-src folder to the classpath:

    (defproject clj-scala "0.1.0-SNAPSHOT"
      :description "FIXME: write description"
      :url "http://example.com/FIXME"
      :license {:name "Eclipse Public License"
                :url "http://www.eclipse.org/legal/epl-v10.html"}
      :dependencies [[org.clojure/clojure "1.3.0"]
                     [org.scala-lang/scala-library "2.7.1"]]
      :compile-path "scala-src" )
    

    Create the directory scala-src, and in that folder create the following Scala class:

    class HelloWorld {
      def sayHelloToClojure(msg: String) =
        "Here's the echo message from Scala: " concat msg
    }
    

    Compile the class using scalac. Now run lein deps to download the dependencies. Launch the Clojure REPL by running lein repl. You can import the Scala class, instantiate it and call the sayHelloToClojure method.

    user=> (import HelloWorld)
    HelloWorld
    user=> (.sayHelloToClojure (HelloWorld.) "Hi there")
    "Here's the echo message from Scala: Hi there"
    

    This is just compatible to the way you could use Scala classes and code out of Java. That can get tricky, a quote from the Frequently Asked Questions – Java Interoperability:

    Using a Scala class from Java can get tricky, in particular if your
    Scala class uses advanced features like generics, polymorphic methods,
    or abstract types. Since Java doesn’t have such language features, you
    have to know something about the encoding scheme of Scala classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that Java have its own garbage collection, but sometimes I want to
Sometimes I want to return the value that is a property of an object
I have a table with a BLOB field that I sometimes want to set
I have a large amount of highly connected nodes that I sometimes want removed
When using the repl, sometimes you want to destroy a variable because it somehow
I use a MacBook Pro. Sometimes I want to pause the execution of a
Sometimes I want to just verify that a function was called rather than have
Sometimes I want to know if an object has a property that I am
I sometimes want to pick a range of commits from a different repository. I
Sometimes I want to run bundle update but only to see which gems need

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.