Yep, we have been using this for a
year or so and this solves the
classpath/jar file location issue nicely.

Hence the usefulness of CLOJURE_HOME and alikes to locate
this single folder from a very simple wrapper script...

Luc P.

Sent from my iPod

On 2010-07-01, at 10:29, Laurent PETIT <laurent.pe...@gmail.com> wrote:

Hello,

note that with java 6 you can specify at once to add all the jars
located in a directory:

java -cp "libs/*" clojure.main

and you can place any jar you want in directory libs.

and this is composable:

java -cp "clojure.jar:libs/*" clojure.main

My 0.02€, just in case you didn't know this (rather recent) possibil ity.

2010/7/1 Paul Moore <p.f.mo...@gmail.com>:
First, a disclaimer - I don't have any problem with the idea of the
classpath in Java. In principle, it's pretty similar to Python's
sys.path. And jar files are much like Python having zip files on
sys.path. So I'm familiar with the idea.

Where I struggle is with the practicalities of managing the classpath.
From what I can tell, there is no way of modifying the classpath from
a running Java/Clojure program (barring use of a custom classloader
which sounds like deep magic). So, assuming that is right, I need to
list my dependencies in advance, when I start the JVM (either by
setting the CLASSPATH environment variable, or with the -classpath
argument).

Generally, I avoid using "global" environment variables like CLASSPATH
(except if they are locally set in a wrapper script), so I guess that
I have the following options for my Clojure applications:

* Use something like lein uberjar to wrap all my dependencies up in one file
* Create an application-specific wrapper, which sets CLASSPATH (or
uses -cp) and runs my application

I have personal reservations about both of these options (I won't
elaborate, to avoid boring people with my prejudices - ask if you
really want to know) so I guess my question would be - is there
another option I have missed?

Python doesn't have these issues because (a) conventionally,
dependencies are installed into the site-packages directory which is
on the standard sys.path - it appears to me that the JVM doesn't have
such an "always available" install location, and (b) for special cases
sys.path can be manipulated at runtime (as noted above, the JVM
doesn't really have this option).

One further question - does having a lot of entries on CLASSPATH slow
down JVM code (either at startup time, or in terms of slowing down
runtime class loading)? Essentially, is there a cost to including
things like clojure-contrib "just in case"? (I don't imagine that the
cost would be significant for just one such case, but I could imagine
that if the practice were to become common, it wouldn't be long before
there were many extra entries, not just one).

I appreciate that this question is only tangentially Clojure-related.
If there is a better forum to discuss this type of question, please
feel free to direct me there.

Thanks,
Paul.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to