如何在类路径中使用通配符添加多个jar? [英] How to use a wildcard in the classpath to add multiple jars?

查看:31
本文介绍了如何在类路径中使用通配符添加多个jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用如此多的 3rd 方库(jar 文件),以至于我的 CLASSPATH 完全搞砸了,因为我必须包含我使用的每个 jar 文件的路径.

I have been using so many 3rd party libraries(jar files) that my CLASSPATH is completely messed up as i have to include the path for every single jar file that i use.

我一直在想是否有办法使用通配符(*) 运算符(如*.jar)将所有jar 文件包含在一个文件夹中.但它似乎不起作用.有没有其他方法可以缩短目前看起来像一篇文章的 CLASSPATH ;) 在我的电脑上?.

I've been wondering if there is a way to include all the jar files in a folder using wildcard(*) operator (like *.jar). But it seems to be not working. Is there any other way that can shorten the CLASSPATH that currently looks like an essay ;) on my PC?.

推荐答案

来自:http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html

类路径条目可以包含基本名称通配符*,这被认为等同于指定目录中所有文件的列表,扩展名为 .jar 或 .JAR.例如,类路径条目 foo/* 指定名为 foo 的目录中的所有 JAR 文件.仅由 * 组成的类路径条目扩展为当前目录中所有 jar 文件的列表.

Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/* specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.

这应该适用于 Java6,不确定 Java5

This should work in Java6, not sure about Java5

(如果它似乎没有按预期工作,请尝试加引号.例如:"foo/*")

(If it seems it does not work as expected, try putting quotes. eg: "foo/*")

这篇关于如何在类路径中使用通配符添加多个jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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