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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:14:55+00:00 2026-05-16T07:14:55+00:00

I’ve been using Lisp on and off, and I’m catching up with clojure. The

  • 0

I’ve been using Lisp on and off, and I’m catching up with clojure.
The good thing about clojure is that I can use all the java functions naturally, and the bad thing about clojure is also that I have to know java function naturally.

For example, I had to spend some time (googling) to find square function in Java (Math/sqrt in clojure notation).

Could you recommend me some good information resource for Java functions (libraries) for clojure users that are not so familiar with Java?

It can be anything – good books, webpages, forums or whatever.

  • 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-16T07:14:56+00:00Added an answer on May 16, 2026 at 7:14 am

    I had similar problems when I first started using Clojure. I had done some Java development years ago, but was still pretty unfamiliar with the libraries out there.

    Intro

    I find the easiest way to use Java is to not really use it. I think a book would be a little bit much to just get started using Java from Clojure. There isn’t that much you really need to know, unless you really start getting down into the JVM/Java libraries. Let me explain.

    Spend more time learning how to use Clojure inside and out, and become familiar with Clojure-Contrib. For instance, sqrt is in generic.math-functions in clojure.contrib.

    Many of the things you’ll need are in fact already in Clojure–but still plenty are not.

    Become familiar with calling conventions and syntactic sugar in Clojure for using Java. e.g. Math/sqrt, as per your example, is calling the static method (which just a function, basically) sqrt from the class Math.

    Anyway, here’s a guide that should help you get started if you find yourself really needing to use Java. I’m going to assume you’ve done some imperative OO programming, but not much else. And even if you haven’t, you should be okay.


    Isaac’s Clojurist’s Guide to Java

    Classes

    A class is a bundle of methods (functions which act on the class) that
    can also be a data type: e.g. to create a new class of the type Double : (Double. 1.2) which initializes the class Double (the period is the syntactic sugar for calling the class constructor methods, which initialize the class with the values you provide) with the value 1.2.

    Now, look at the Double class in the Java 6 API:

    Double
    
    public Double(double value)
    
    Constructs a newly allocated Double object that represents the 
    primitive double argument.
    
    Parameters:
    value - the value to be represented by the Double.
    

    So you can see what happened there. You "built" a new Double with value 1.2, which is a double. A little confusing there, but really a Double is a class that represents a Double and can do things relating to doubles.

    Static Methods

    For instance, to parse a Double value out of a string, we can use the static method (meaning we don’t need a particular instance of Double, we can just call it like we called sqrt) parseDouble(String s):

    (Double/parseDouble "1.2") => 1.2
    

    Not to tricky there.

    Nonstatic Methods

    Say we want to use a Java class that we initialized to something. Not too difficult:

    (-> (String. "Hey there") ;; make a new String object
        (.toUpperCase)) ;; pass it to .toUpperCase (look up -> to see what it does)
                        ;; toUpperCase is a non-static method
    
    => "HEY THERE"
    

    So now we’ve used a method which is not static, and which requires a real, live String object to deal with. Let’s look at how the docs say it works:

    toUpperCase
    
    public String toUpperCase()
    
    Converts all of the characters in this String to upper case using 
    the rules of the default locale. This method is equivalent to
    toUpperCase(Locale.getDefault()).
    
    Returns:
    the String, converted to uppercase.
    

    So here we have a method which returns a string (as shown by the "String" after the public in the definition, and takes no parameters. But wait! It does take a parameter. In Python, it’d be the implicit parameter self: this is called this in Java.

    We could also use the method like this: (.toUpper (String. "Hey there")) and get the same result.

    More on Methods

    Since you deal with mutable data and classes in Java, you need to be able to apply functions to Classes (instances of Classes, really) and not expect a return value.

    For instance, say we’re dealing with a JFrame from the javax.swing library. We might need to do a number of things to it, not with it (you generally operate with values, not on them in functional languages). We can, like this:

    (doto (JFrame. "My Frame!");; clever name
       (.setContentPane ... here we'd add a JPanel or something to the JFrame)
       (.pack) ;; this simply arranges the stuff in the frame–don't worry about it
       (.setVisibleTrue)) ;; this makes the Frame visible 
    

    doto just passes its first argument to all the other functions you supply it, and passes it as the first argument to them. So here we’re just doing a lot of things to the JFrame that don’t return anything in particular. All these methods are listed as methods of the JFrame in the documentation (or its superclasses… don’t worry about those yet).

    Wrapping up

    This should prepare you for now exploring the JavaDocs yourself. Here you’ll find everything that is available to you in a standard Java 1.6 install. There will be new concepts, but a quick Google search should answer most of your questions, and you can always come back here with specific ones.

    Be sure to look into the other important Clojure functions like proxy and reify as well as extend-type and its friends. I don’t often use them, but when I need to, they can be invaluable. I still am understanding them myself, in fact.

    There’s a ton out there, but it’s mostly a problem of volume rather than complexity. It’s not a bad problem to have.

    Additional reading:

    • Static or Nonstatic? ;; a guide to statis vs. nonstatic methods
    • The Java Class Library ;; an overview of what’s out there, with a nice picture
    • The JavaDocs ;; linked above
    • Clojure Java Interop Docs ;; from the Clojure website
    • Best Java Books ;; as per clartaq’s answer
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping 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.