java中windows目录通配符,Java 7命令行在Windows上的通配符扩展(7?)

I observe a strange behavior of wildcard expansion behavior for Java7 on Windows.

For centuries there was a clean difference between "*" versus *.

Seems this it not longer true for Java7 (at least on Windows7).

I noticed the problem when using a wildcard classpath.

In despite of quoting the wildcard-classpath it gets expanded.

Thus it seems not possible any more to pass a wildcard to the java application.

So using java -cp "somewhere/*" will fail (as does "somewhere\*").

A workaround seems to be: java -cp "somewhere/*;" which inhibits the expansion.

To verify the behavior I wrote a small Echo.java class.

I found that using java 1.6.0 quoted "*" and plain * works like expected,

whereas on Java7 I always got the expanded wildcard.

Until now this was observed on Windows7, don't know what happens on XP.

The problem arises, since wildcards on Windows are never ever expanded by dark age CMD.EXE (like any shell does on UNIX). Instead each executable has to perform this explicitly using setargv.obj.

I found two related issues which seem to describe a similar problem:

Is this observed by someone else?

Or are there some obscure Windows or batch-file settings to control this?

Dieter.

解决方案

Yes, I noticed the same issue.

It's explained as a 'known issue' in the release notes for Java7 update 4.

Here is the bug report. The fix will be delivered in Java7 update 8 (current release is update 6).

Note that there isn't a shell-options workaround, because in Windows, the shell doesn't handle wildcard expansion. (Whereas in Unixes, the shell performs the expansion).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值