Java:如何在java中设置类路径 [英] Java: how to set the classpath in java

查看:122
本文介绍了Java:如何在java中设置类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多jar文件要添加到我的类路径中,所以每当我编译我的java文件时,我最终会得到如下命令:

I've many jar files to add to my classpath, so everytime I compile my java file I end up with a command like this:

javac -cp commons-digester-2.1/commons-digester-2.1.jar:lucene-core-3.0.3.jar:commons-logging-1.1.1/commons-logging-1.1.1.jar:commons-beanutils-core-1.7.0.jar:. CollectionIndexer.java

我试过使用:

set CLASSPATH=commons-digester-2.1/commons-digester-2.1.jar:lucene-core-3.0.3.jar:commons-logging-1.1.1/commons-logging-1.1.1.jar:commons-beanutils-core-1.7.0.jar:.

然后:

javac CollectionIndexer.java

但是根本没有添加jar:我得到了由于丢失的罐子导致错误...
谢谢

but the jar are not added at all: I get error due to the missing jars... thanks

推荐答案

也许你想尝试使用maven来构建你应用?
它很容易设置,它消除了依赖管理的所有问题。

maybe you want to try to use maven for build you application? It's really easy to setup and it annihilate all problems with dependency management.

同样来自java 6你可以在classpath中使用通配符:
设置CLASSPATH = my_libs \ *;

also from java 6 you can use wildcards in classpath: set CLASSPATH=my_libs\*;

这篇关于Java:如何在java中设置类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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