34

I am a pretty decent programmer in Java, however I am new to programming in Clojure.

In Java, to force an exit of a program, the code used is System.exit(0). Is there any equivalent to this code is Clojure?

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126

2 Answers2

67

Given that part of the attractiveness of Clojure is that you can use Java class libraries, why not just do:

(System/exit 0)
Pavel Minaev
  • 99,783
  • 25
  • 219
  • 289
8

For a more complete reference, you call any Java classes static methods by specifying

(my.package.class/staticMethodName arg1 arg2 etc)

java.lang.* is loaded automagically for you already though if it where not you could call it with

(java.lang.System/exit 0)
Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126
Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284