Okay. So here’s my question: I am making a data parser in Clojure. One part of my program is that it has to be able to graph the data. I figure, I’ll use jFreeChart. However, I have absolutely NO IDEA how to include stuff in JAR files. What I mean is: if I have a app.jar file in my classpath, I don’t seem to be able to do:
import app.thing.thing2
without changing the classpath to be inside the jar file.
The idea here is that I don’t think I can change my classpath since I need to set it to run Clojure (Or do I?). The global classpath is currently /usr/share/java.
And please don’t ask me to use Maven, Ant or any project-building tool unless it is the only way to do this. This is a script for personal use that doesn’t need or want a whole lot of overhead.
I wonder if I should just unpack every JAR file, so that I can reference the directory structure? Is this bad?
Let me know if you need any clarifications!
The content of the (Java)
CLASSPATHenvironment variable is available to Clojure so if you add your jar to the global classpath before to run Clojure, you’ll “see” it:But, in my opinion, this is not the “clean” way to add a jar to Clojure’s classpath (because this makes the library visible to any Java program and may not be desired). Instead, you should use the
CLOJURE_EXTenvironment variable. This is how this variable is documented:On my system, it is defined as below:
So, to add jfreechart.jar (or any other library) to Clojures’s classpath, copy it (or add a symlink pointing to it) in the directory defined in the
CLOJURE_EXTvariable.And by the way (I’m sorry but your question is not that clear), if you want to bundle some Java classes into a jar, the command is something like that:
You’ll find documentation of
jar– the Java Archive Tool – here.