如何使用路径作为包含空格的参数运行javac? [英] How to run javac with paths as argument that contain white spaces?

查看:58
本文介绍了如何使用路径作为包含空格的参数运行javac?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行以下

javac -Xlint:unchecked -classpath C:/Users/a b/workspace/ @C:/Users/a b/workspace/files_to_compile

但是我得到一个

javac: invalid flag C:/users/a

我也尝试用双引号将两个路径都包围起来,但这似乎没有帮助:

javac -Xlint:unchecked -classpath "C:/Users/a b/workspace/" @"C:/Users/a b/workspace/files_to_compile"

我做错了什么?相同的代码在其他计算机上也可以正常工作(可能是因为它们的路径中没有空格.).

谢谢

解决方案

我终于想出了解决该问题的方法,我想这里没有人会猜到它.

答案的根源在于,文件列表的内容(在args中用@表示)通常具有其字符串中的每个字符串,其初始子字符串等于通过类路径和路径传递的子字符串. @文件.

所以..

麻烦不在于建议的命令行参数,而是@文件的内容.

文件的每一行都必须放在其自己的行中,并用引号引起来,并且要考虑到如果您在Windows中,则必须以C:\\a\\b\\c.txt的形式放置文件名! /p>

I am trying to run the following

javac -Xlint:unchecked -classpath C:/Users/a b/workspace/ @C:/Users/a b/workspace/files_to_compile

but I'm getting a

javac: invalid flag C:/users/a

I've also tried to surround both paths with double quotes but it doesn't seem to help a bit:

javac -Xlint:unchecked -classpath "C:/Users/a b/workspace/" @"C:/Users/a b/workspace/files_to_compile"

What am I doing wrong? This same code worked correctly in other computers (probably because they didn't have any white space in their paths..).

Thanks

解决方案

I've finally come up with the solution to the issue, and I guess no one here could have guessed it.

The cue to the answer lies with the fact that the contents of the files list (signaled as @ in the args) generally will have each one of its strings with the initial substring equal to what one passes as both the class path and the @ file.

so..

The trouble was never the command line parameters, as suggested, but with the contents of the @ file.

Each line of the file must be put in its own line, surrounded by quotes, and having into consideration that if you're in windows, you have to put the file names in the form of C:\\a\\b\\c.txt!!!

这篇关于如何使用路径作为包含空格的参数运行javac?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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