【发布时间】:2014-03-21 00:58:57
【问题描述】:
我有一个名为 $CLASSPATH 的环境变量,我用它作为 java 类路径来运行某个 java 代码。
这个$CLASSPATH 变量很长。它的大小约为66427字节(see how long it is)
现在这是奇怪的行为。
当我将某个 jar 文件(例如 bar.jar)附加到 $CLASSPATH 的开始时,该 jar 文件被添加到类路径中,并且我的代码运行良好。
我在 shell 脚本中这样做,如下所示,
CLASSPATH=/home/foo/bar.jar:$CLASSPATH
但是,当我将 bar.jar 附加到 $CLASSPATH 的 end 时,由于缺少 bar.jar 文件,我的代码会出现异常!
CLASSPATH=$CLASSPATH:/home/foo/bar.jar
为什么会有这种奇怪的行为?
我这里有什么遗漏吗?
更新:
如果适用,请查看 shell 上 xargs --show-limits 命令生成的输出。
foo@foo-laptop:~$ xargs --show-limits
Your environment variables take up 3632 bytes
POSIX upper limit on argument length (this system): 2091472
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2087840
Size of command buffer we are actually using: 131072
【问题讨论】: