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

  • SEARCH
  • Home
  • 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 6670217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:14:32+00:00 2026-05-26T03:14:32+00:00

java -cp clojure.jar clojure.main compile.clj this is compiling the clojure code. javac CalculateSum.java compiling

  • 0

java -cp clojure.jar clojure.main compile.clj this is compiling the clojure code.
javac CalculateSum.java compiling java code.
jar cvf sum.jar *.class getting jar file of class files.

java CalculateSum is running main and giving output correctly.
How to run jar file from java environment?
like java -cp clojure.jar;sum.jar clojure.main CalculateSum where CalculateSum is main class.

sample code
_utils.clj_

(ns utils
(:gen-class :name Utils
:methods [#^{:static true} [sum [java.util.Collection] long]]))
(defn sumx [coll] (reduce + coll))
(defn -sum [coll] (sumx coll))

compile.clj

(set! *compile-path* "./")
(compile 'utils)

CalculateSum.java
public class CalculateSum {
public static void main(String[] args) {
java.util.List<Integer> xs = new java.util.ArrayList<Integer>();
xs.add(10);
xs.add(5);
System.out.println(Utils.sum(xs));
}
}

Aim is to craete jar file out of this code. and run jar file

java should call clojure code, execute it and print result

  • 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-26T03:14:33+00:00Added an answer on May 26, 2026 at 3:14 am

    Okay, so there are two things:

    • To run it just from a jar file rather than making it an executable jar file, you should be fine with just:

      java -cp sum.jar CalculateSum
      

      or possibly (if it needs classes from closure.jar at execution time)

      java -cp closure.jar;sum.jar CalculateSum
      
    • To turn it into an executable jar file which you can run with

      java -jar sum.jar
      

      you’ll need a manifest file including a Main-Class attribute letting you set the entry point, and possibly a Class-Path attribute to add the closure.jar file to the jar’s classpath.

    Follow the links for more details.

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

Sidebar

Related Questions

this is the command. java -cp clojure.jar;sum.jar CalculateSum sum.jar is a jar file made
I am trying to compile some Clojure code to Java using the Clojure 1.2
Like so: java -cp clojure.jar clojure.main Clojure 1.2.0 user=> (defn f [x] x) #'user/f
user=> (use '[clojure.contrib.duck-streams]) java.io.FileNotFoundException: Could not locate clojure/contrib/duck_streams__in it.class or clojure/contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)
I have the following contents in src/main/clojure/za/co/pb/maven_test/test.clj file: (ns za.co.pb.maven-test.test (:gen-class)) (defn -main []
I make a clj script for running clojure as follows. java -cp $CLOJURE_JAR:$CLASSPATH clojure.main
(Java question) If I reference a field in an inner class, does this cause
I am typing this at the PowerShell command line: java -jar closure-compiler.jar --js temp1.js
Begin Edit: Primarily I want my Clojure program to use a Java class. I've
I'm learning how to extend Java classes in Clojure, but I don't see a

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.