Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A "hello world" using Netbeans 7.0 Enclojure 1.5

I just started learning Clojure. I would like to use Netbeans but I have no idea how to setup a simple app the spits out anything. I followed the setup for the Enclojure plugin and everything seems good. Can anybody give a short tutorial or a hint to one on the setup.

like image 653
Clutch Avatar asked Jul 08 '11 02:07

Clutch


1 Answers

Prerequisites:

Netbeans 7
EnClojure Plugin
Maven set up correctly
    Maven installed
    Maven Proxy setup if behind a proxy
    Netbeans: Tools > Options > Miscellaneous > Maven

Project Setup:

Menu File > New Project > Clojure > Clojure 1.2 Maven Project
Projectname= HelloWorld
Default Namespace= com.jfcorbet.helloword

Browse Project:

Projects Window > Source Packages > com.jfcorbet > helloworld.clj

You'll see:

(ns com.jfcorbet.helloworld
    ;(:import )
    ;(:require )
)

Add:

(defn hello
"Prints Hello and name parameter"
     [name]
     (println (str "Hello " name)))

(hello "Jean-François")

and save.

Now Rightclick your project and choose "Build with Dependencies", this should make Maven download the clojure and contrib libraries, and take care of the dependencies.

then

Rightclick your project and choose "Start Project REPL"
    Project window > helloworld.clj > RMB > choose "Load Sources in Repl"
    or select source text and RMB > "Evaluate Expr in REPL"
like image 51
NielsK Avatar answered Oct 19 '22 17:10

NielsK