最简单的方法来管理我的CLASSPATH? [英] Easiest way to manage my CLASSPATH?

查看:184
本文介绍了最简单的方法来管理我的CLASSPATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始玩Clojure有点,我的Java体验是相当有限。我来自Ruby和OO的动态世界,所以事情的功能方面是非常有趣!

无论如何,我发现库和各种工具使用和Pragmatic Clojure Book的教程文件),一切都通常要求在CLASSPATH中放置文件,以便Clojure可以查看该库以供使用。



有这样的东西作为好的CLASSPATH实践?我想要只有一个CLASSPATH只需要我需要的文件的外部库,或者我可以去折腾任何库或文件我需要在一个目录,只是定义为我的CLASSPATH,只需要所需的? p>

如果它有帮助,我是一个OSX和Emacs用户(使用slime和swank-clojure)。

解决方案

就我个人而言,我使用Phil Hagelberg的 clojure-project elisp函数的变体,参见此帖到Clojure组。它为您将要处理的项目正确设置类路径,然后启动SLIME。 ( EDIT:您需要更改分配给 swank-clojure-jar-path 的值,以指向 clojure.jar 。我使用(expand-file-name〜/ .clojure / clojure.jar)作为默认值。 )



为了回答关于在classpath上一切都在所有时间vs只扔在所需要的问题:据我所知,没有什么会实际上如果你采取第一种方法(我知道我这样做的实验目的),但显然,事情可能会打破与第一种方法(见cjstehno的注释下面),在一个正确的项目,我发现第二个是更清洁。在某些时候,如果只是告诉leiningen(或maven)关于它 - 为什么不去保持标签,你必须确定使用什么libs(和它们的版本)。


I'm beginning to play with Clojure a bit and my Java experience is pretty limited. I'm coming from the dynamic world of Ruby and OO, so the functional side of things is very interesting!

Anyway, as I discover libraries and various tools for use (and the tutorial files for the Pragmatic Clojure Book), everything typically calls for placing files in the CLASSPATH in order for Clojure to see the library for use.

Is there such thing as good CLASSPATH practice? Would I ever want to only have a CLASSPATH with just the external libraries of files I need or can I go ahead toss any library or file I would ever need in a directory and simply define it as my CLASSPATH and only require what's needed?

If it helps, I'm an OSX and Emacs user (Using slime and swank-clojure).

解决方案

Personally, I'm using a variant of a clojure-project elisp function by Phil Hagelberg, see source in this post to the Clojure group. It sets up the classpath appropriately for the project you'll be working on, then launches SLIME. (EDIT: You'll need to change the value which gets assigned to swank-clojure-jar-path to point to clojure.jar. I'm using (expand-file-name "~/.clojure/clojure.jar") as the default.)

To answer the question about having everything on the classpath all the time vs only throwing in what's needed: to the best of my knowledge, nothing will actually break if you take the first approach (I know I do that for experimental purposes), but apparently things might break with the first approach (see cjstehno's comment below) and in a proper project I find the second to be cleaner. At some point it'll be necessary to determine what libs are being used (and which versions of them), if only to tell leiningen (or maven) about it -- why not keep tabs on it as you go.

这篇关于最简单的方法来管理我的CLASSPATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆