空间问题蚂蚁java任务 [英] ant java task with space issue

查看:199
本文介绍了空间问题蚂蚁java任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是想通过ant脚本来执行一个jar文件。像这样

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具有完整路径的jar文件和包含在它的一些空间

当我执行在Linux,也没有问题。但是,当我做同样的在Windows上我得到了错误。 java任务未能找到罐子!我试着像引号(),取而代之的空间包裹的文件路径各不相同的变异QUOT ;,试图用反斜杠逃逸等非工程!

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对不起,不提供我得到了完整的错误消息。我现在离开我的Windows电脑。作为一种变通方法,我决定复制的jar到C:\\并使用的替代。

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.

推荐答案

处理属性中的空间问题的建议方法是将它们放在
额外'',这应该在大多数情况下,即使是最好使用不带空格结果的路径

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

<java jar="'${jar.file}'" fork="true" failonerror="true">
   <arg line="${jar.args}"/>
</java>

应该工作,在我的评论已经提到。结果

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 :

<project>
 <property name="jar.file" value="foobar.jar"/>
 <property name="jar.dir" value="/home/rosebud/temp/path with blanks"/>

 <java
   dir="${jar.dir}"
   jar="${jar.dir}/${jar.file}"
   fork="true"
   failonerror="true"
   >
   <arg value="..." />
 </java>
</project>

和它的作品竟然也有空格的路径F.E.上述结果的段

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 :

"'${property with blanks}'"

但事实并非如此。

but it doesn't.

这篇关于空间问题蚂蚁java任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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