Compiling clojure manually

Source: Internet
Author: User
Tags macbook

The project uses Clojure, generally will use the Leinigin or Maven plugin to compile, the official network on the manual compilation of a pen, read a bit abstract.



Clojure Environment:

[Jw-macbook]:d emo johnwang$ ll $CLOJURE _home

Total 9280

[email protected] Johnwang Staff 476 2 3 10:59.

Drwxr-xr-x Johnwang Staff 510 3 26 14:32.. /

[Email protected] 1 Johnwang staff 6508 2 3 10:54 build.xml

[Email protected] 1 Johnwang staff 64207 2 3 10:54 changes.md

[Email protected] 1 Johnwang staff 962588 2 3 10:54 Clojure-1.6.0-slim.jar

[Email protected] 1 Johnwang staff 3664472 2 3 10:54 Clojure-1.6.0.jar

[Email protected] 1 Johnwang staff 1683 2 3 10:54 CLOJURE.IML

[Email protected] 3 Johnwang staff 102 2 3 10:54 doc/

[Email protected] 1 Johnwang staff 12917 2 3 10:54 epl-v10.html

[Email protected] 1 Johnwang staff 7754 2 3 10:54 pom.xml

[Email protected] 1 Johnwang staff 13139 2 3 10:54 readme.txt

[Email protected] 7 Johnwang staff 238 2 3 10:54 src/

Drwxr-xr-x Johnwang Staff 340 2 3 10:59 target/

[Email protected] 4 Johnwang staff 136 2 3 10:54 test/



1. Create a Project Catalog

mkdir Demo

CD Demo

mkdir Src/clj/com/baofeng/data/demo

mkdir classes


Classes directory needs to be created manually, do not create in the subsequent compilation process will not be reported to find the file error, this directory is the default directory of *compile-path*


2.code

VI SRC/CLJ/COM/BAOFENG/DATA/DEMO/TEST.CLJ

The code is as follows:


(ns com.baofeng.data.demo.test

(: Gen-class

: Name com.baofeng.data.demo.MainTest))


(defn -main

[& args]

(prn args))


Gen-class represents the Clojure source file that will generate the. class files

Name represents the class name of the generated. class file


3. Start a repl and compile

[Jw-macbook]:d emo johnwang$ java-cp src/clj:/users/johnwang/dev/clojure-1.6.0/clojure-1.6.0.jar clojure.main

Clojure 1.6.0

user=> (Compile ' com.baofeng.data.demo.test)

Com.baofeng.data.demo.test

User=>



4. You can see that the compiled. class file has been generated under the classes directory

[Jw-macbook]:d emo johnwang$ ll classes/com/baofeng/data/demo/

Total 40

Drwxr-xr-x 7 Johnwang Staff 238 4 13 11:51./

Drwxr-xr-x 3 Johnwang Staff 102 4 13 11:50.. /

-rw-r--r--1 Johnwang Staff 1831 4 11:51 Maintest.class

-rw-r--r--1 Johnwang Staff 929 4 11:51 Test$_main.class

-rw-r--r--1 Johnwang Staff 1357 4 11:51 Test$fn__4.class

-rw-r--r--1 Johnwang Staff 1528 4 11:51 Test$loading__4958__auto__.class


-rw-r--r--1 Johnwang Staff 2939 4 11:51 Test__init.class



In addition to test, several other. class files are generated.


5. Running

JAVA-CP Classes:/users/johnwang/dev/clojure-1.6.0/clojure-1.6.0.jar com.baofeng.data.demo.MainTest "AAA"






Compiling clojure manually

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.