ant java任务有空间问题
我试图通过 ant 脚本执行 jar 文件。就像这个
<java jar="${jar.file}" fork="true" failonerror="true">
<arg line="${jar.args}"/>
</java>
jar.file 具有 jar 文件的完整路径,并且其中包含一些空格。
当我在Linux上执行时,没有问题。但当我在 Windows 上执行相同操作时,出现错误。 java 任务找不到 jar!我尝试了所有不同的变体,例如用引号(“)包裹文件路径,用”替换空格,尝试用反斜杠转义等等。不起作用!
有人遇到过这个问题吗?只是想知道这是 Ant 的限制还是我错过了一些东西。
PS 很抱歉没有提供我收到的完整错误消息。我现在没有使用 Windows PC。作为解决方法,我决定将 jar 复制到 C:\ 并使用它。
I was trying to execute a jar file via ant script. Like this
<java jar="${jar.file}" fork="true" failonerror="true">
<arg line="${jar.args}"/>
</java>
jar.file has full path to the jar file and contains some space in it.
When I executed that on Linux, there was no problem. But when I do the same on Windows I got error. java task couldn't locate the jar! I've tried all different variations like wrapping the file path with quote ("), replaced space with ", tried escaping with backslash, etc. Non works!
Did anyone come across this issue? Just wondering if this is Ant's limitation or I missed something.
P.S Sorry for not providing the full error message I got. I'm away of my Windows PC right now. As a workaround, I decided to copy the jar to C:\ and used that instead.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理属性内空间问题的推荐方法是将它们放入
extra '',在大多数情况下应该有效,最好使用不带空格的路径
应该有效,正如我的评论中已经提到的。
编辑
你是对的,它不会工作,因为相对路径只有 jar 属性
事实上,我想到了类似的东西:
并且它也出乎意料地适用于路径中的空格,如上面代码片段中的 fe
认为处理空间问题的标准方法将适合其他情况:
但它没有。
The recommended way to handle space problems within properties is to put them in
extra '', which should work in most cases, even better to use a path without spaces
should work, as already mentioned in my comment.
edit
you're right it won't work because of the relative path with only jar attribute
in fact i thought of something like :
and it works unexpectedly also with spaces in path as f.e. in the snippet above
thought the standard way to handle space problems would fit in as in other cases :
but it doesn't.