CLASSPATH 中的空格
我正在 Windows PC 上工作并且上面有 cygwin! 我已将所有罐子组织在几个目录中的一个目录下! 我正在编写一个 bash
脚本,通过迭代作为参数传递的目录来设置 CLASSPATH
,如下所示:
for JAR_FILE in `ls *.jar`
do
CLASSPATH="$DIRECTORY_TO_LOOK_FOR_JARS"/$JAR_FILE:$CLASSPATH
done
每当传递的目录中有空格时 < code>/cygdrive/c/Documents and Settings/user/My Jars 并且我运行 java -cp $CLASSPATH somepackage.someclass
,它抛出一个错误,指出该类 和找不到
,因为 CLASSPATH 变量在 /cygdrive/c/Documents
之后被分割。
有人可以帮我解决这个问题吗?
I am working on a Windows PC and have cygwin on it!
I have organized all my jars under a directory within a few directories!
I am writing a bash
script to set the CLASSPATH
by iterating through the directory that is passed as a parameter as follows:
for JAR_FILE in `ls *.jar`
do
CLASSPATH="$DIRECTORY_TO_LOOK_FOR_JARS"/$JAR_FILE:$CLASSPATH
done
Whenever there are spaces in the directory that is passed like /cygdrive/c/Documents and Settings/user/My Jars
and I run java -cp $CLASSPATH somepackage.someclass
, it throws an error stating that the class and
is not found, because the CLASSPATH variable is getting split after /cygdrive/c/Documents
.
Can someone help me to solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅这篇文章。
您可以将完整的类路径包含在双引号中
,也可以将每个 jar 包含在类路径中。
在您的情况下,类似这样的内容:
很难看到,但我移动了结束双引号。
See this article.
You could enclose either the full classpath in double qoutes
or each jar in your classpath
In your case something like that:
Hard to see, but I moved the closing double qoute.