Don't bring your laptop to work day
Door Gert-Jan van de Streek / feb 2012 / 1 Min
Door Gert-Jan van de Streek / / 1 min
When you get used to the REPL in Clojure it's hard to go back to the compile / redeploy round trip in Java. In very complex projects/products it's nice to have a REPL around where you can quickly try stuff. But wait, Clojure runs on the VM and the Java interop is great. Why not add the Clojure REPL to your Java project and take this as a start for adding Clojure modules!
Adding the REPL is as simple as requiring clojure.core and and call start-server on the nrepl-server. To do this from Java you need the clojure java api. When you... ok, ok, I'll just show you the code:
Our code does not specify a port, so you need to find out what port the repl is using (use netstat -a | grep LISTEN or the likes). When you know the port, connect to the repl with leiningen:
In our case we have embedded the REPL inside JIRA, which enables us to look around and see what all the magic managers and services can do for us:
That's it, now you have a way to look around inside a Java process. That's a start. You are now ready to mix and match Java and Clojure for new development. What's keeping you?
| Software Development
Door Gert-Jan van de Streek / okt 2024
Dan denken we dat dit ook wat voor jou is.