Skip to content

Instantly share code, notes, and snippets.

@mbobesic
Created March 4, 2016 11:03
Show Gist options
  • Save mbobesic/bbdea9a1fae1927057b8 to your computer and use it in GitHub Desktop.
Save mbobesic/bbdea9a1fae1927057b8 to your computer and use it in GitHub Desktop.
Starting a clojure repl from java

Clojure REPL in java

Dependencies

<dependencies>
  <dependency>
    <groupId>org.clojure</groupId>
    <artifactId>clojure</artifactId>
    <version>1.8.0</version>
  </dependency>
  <dependency>
    <groupId>org.clojure</groupId>
    <artifactId>tools.nrepl</artifactId>
    <version>0.2.12</version>
  </dependency>
</dependencies>

Java code

public static void main(String[] args){
    IFn require = Clojure.var("clojure.core", "require");
    require.invoke(Clojure.read("clojure.tools.nrepl.server"));
    IFn server = Clojure.var("clojure.tools.nrepl.server","start-server");
    server.invoke(Clojure.read(":port"), Clojure.read("8083"));
}

Connecting to repl

lein repl :connect localhost:8083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment