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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:09:16+00:00 2026-05-25T03:09:16+00:00

At the following link Calling clojure from java , it is illustrated how to

  • 0

At the following link Calling clojure from java , it is illustrated how to write a piece of clojure code, whose functionality we can then invoke directly in java source code. To reproduce, we have a clojure project called tiny, which within it has a tiny.clj source file. The tiny.clj file contains the following code :

(ns tiny
  (:gen-class
    :name com.domain.tiny
    :methods [#^{:static true} [binomial [int int] double]]))

(defn binomial
  "Calculate the binomial coefficient."
  [n k]
  (let [a (inc n)]
    (loop [b 1
           c 1]
      (if (> b k)
        c
        (recur (inc b) (* (/ (- a b) b) c))))))

(defn -binomial
  "A Java-callable wrapper around the 'binomial' function."
  [n k]
  (binomial n k))

(defn -main []
  (println (str "(binomial 5 3): " (binomial 5 3)))
  (println (str "(binomial 10042 111): " (binomial 10042 111)))
)

This is then exported into a ttt.jar file, which is then added to the “Referenced Libraries” of the tinyJava project (which is a java project). Inside the tinyJava project there is a Main.java file, which has the following code :

import com.domain.tiny;

public class Main {

    public static void main(String[] args) {

        int j;
        j = (int)tiny.binomial(5, 3);
        System.out.println("(binomial 5 3): " + j);
        System.out.println("(binomial 10042, 111): " + tiny.binomial(10042, 111));

    }

}

The output is then :

(binomial 5 3): 10
(binomial 10042, 111): 4.9068389575068143E263

My question is, at the following point in Main.java :

j = (int)tiny.binomial(5, 3);

is it possible to step into the clojure source code? I have tried and it did not work.

Thanks

[EDIT] : the way I added the jar to the Referenced Libraries was as follows :

1)Rightclick on project tinyJava & choose properties

2)Choose : Java Build Path

3)Choose : Libraries

4)Click : “Add External Jars”

5)Then go to the location of ttt.jar

[EDIT 2] : For a scala project it seems that one can achieve this in a slightly different manner (see below), whereby one links the projects rather than explicitly exporting a jar file.

  • 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-05-25T03:09:17+00:00Added an answer on May 25, 2026 at 3:09 am

    For example this seems to be quite easy to do with Scala (note the following article also discusses interop : How do you call Scala objects from Java?).

    What I did was as follows :

    1)Set up a Scala project called firstScala, and add a file MyPrinter.scala with the following code :

    class MyPrinter{ 
      def printTerm() {
            print("hello");
      }
    }
    

    2)Then I created a Java project called firstScalaJava, to which I then added a file called Main.java with the following code :

    class Main {
        public static void main(String args[]) {
            MyPrinter myPrint = new MyPrinter();
            myPrint.printTerm();
        }
    }
    

    3)Then I right clicked on firstScalaJava, selected Properties, chose Java Build Path, chose Projects tab, clicked “Add”, and then selected the firstScala project.

    4)Then if I put a breakpoint at “myPrint.printTerm();” and clicked F5 when the debugger has stopped at this point, the debugger automatically walks into the Scala source file.

    The nice thing about this is that I did not need to export any jar files or anything like that. This is appealing because upon changing the Scala code one does not need to do anything (eclipse automatically rebuilds the scala project when one attempts to run the java project thereafter), whereas if I changed the Clojure code I would need to re-export the jar etc… (note that linking the projects in the manner described above does not work for the clojure case)

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

Sidebar

Related Questions

following this link i was able to load and read pixels from a .gif.
ModelMultipleChoiceField doesn't select initial choices and I can't make the following fix (link below)
I have the following JavaScript code: Link In which the function makewindows does not
In my following code, I am calling function Make Request that is located in
I have the following link function MyLinqToSQLTable.Where(x => x.objectID == paramObjectID).ToList(); I most of
In the following link <a href=\#\ onclick=javascript:print(\\) style=\color:blue;\>Print</a> <script> function print() { //How to
With reference to the following link: http://docs.python.org/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe I wanted to know if the following:
In the following link http://www.faqs.org/docs/Linux-HOWTO/NFS-HOWTO.html It said a process is not killable except by
I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
I have created a static library following this link . But I am facing

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.