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

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

问题描述

我正在尝试运行以下内容

I am trying to run the following

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

但我得到了一个

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..).

谢谢

推荐答案

我终于想出了解决这个问题的办法,我想这里没有人能猜到.

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

答案的线索在于这样一个事实,即文件列表的内容(在 args 中用 @ 表示)通常会使其每个字符串的初始子字符串等于作为类路径和@ 文件.

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.

所以..

问题从来不是建议的命令行参数,而是@文件的内容.

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

文件的每一行必须放在自己的行中,用引号括起来,并考虑到如果你在windows中,你必须以C:\的形式放置文件名a\b\c.txt!!!

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天全站免登陆