Skip to content

Instantly share code, notes, and snippets.

@lildata
Last active January 5, 2016 14:47
Show Gist options
  • Save lildata/ac9b0770b00a5960d78b to your computer and use it in GitHub Desktop.
Save lildata/ac9b0770b00a5960d78b to your computer and use it in GitHub Desktop.
(ns learning.hello
  (:gen-class))

The :gen-class directive in the ns declaration tells Clojure to generate a named Java class when it compiles the namespace.

You can compile in the repl !!

user=> (load "learning/hello")
nil
user=> (compile 'learning.hello)
learning.hello

When you change a file and then want to test in a running REPL

(use 'xxx.xxx :reload-all)

Get the type of the last result

(type *1)

by default, the classpath includes the current directory . -> that's why $java HelloWorld works...

Packages provide a way for you to organize classes. Your directory structure must reflect your package names

Manually create a jar $jar cvfe hello.jar HelloWorld *.class ns*/*.class the file META-INF/MANIFEST.MF is automatically generated the option e and HelloWorld create an entry point which contain the main Main-Class: HelloWorld

To see the content $jar tf hello.jar

we need to control what is loaded in

(. System getProperty "java.library.path")

In lein we can simply use :jvm-opts to control the jvm options

:jvm -opts ["-Djava.library.path=C:\\Some\\Path"]

I'm not sure this is the best way, tho

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment