javac classpath选项在当前目录中有多个jar文件导致错误 [英] javac classpath option with multiple jar files in current directory causing error

查看:115
本文介绍了javac classpath选项在当前目录中有多个jar文件导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:Windows 7,Java 6.

Environment: Windows 7, Java 6.

尝试使用-cp选项编译.java文件.该文件使用当前目录中的一个jar文件,以及当前目录中的一些其他jar文件.

Trying to compile a .java file with -cp option. The file uses a single jar file that's in the current directory ALONG WITH some other jar files in the current directory.

javac -cp ./*.jar MyFile.java

不起作用.

javac -cp ./* MyFile.java 

不起作用

javac -cp ./MyJar.jar MyFile.java

有效

前两种情况,我收到无效的标志错误.有人可以解释这种行为吗?

First two cases, I get a invalid flag error. Can someone explain this behavior?

我检查了是否存在空格问题,完整文件路径中的任何地方都没有空格.

And I checked if it is spaces issue, there are no spaces anywhere in my full file paths.

推荐答案

注释以及此问题可能已经在这里有了答案"中提供的两个链接的引用来源,但并不完全解释观察到的行为.

The quoted sources for the two links provided in the comments as well as in the "This question may already have an answer here:", do not completely explain the observed behavior.

javac -cp ./*.jar MyFile.java

javac -cp ./*.jar MyFile.java

不起作用,因为在这种情况下通配符*的用法与正常用法不同.这可以从文档中了解. *始终代表完整文件,而不代表部分文件名.

Won't work, because the wildcard * usage in this context differs from normal usage. This can be understood from the documentation. * always represents full file(s) and not partial file names.

javac -cp ./* MyFile.java

javac -cp ./* MyFile.java

本来应该工作的.显然在Windows中使用双引号和/或分号.作品:

Should have worked. Apparently using double quotes and/or a semi-colon in windows. works:

javac -cp"./*"; MyFile.java

javac -cp "./*" MyFile.java

javac -cp ./*; MyFile.java

javac -cp ./*; MyFile.java

javac -cp"./*;"; MyFile.java

javac -cp "./*;" MyFile.java

javac -cp *; MyFile.java

javac -cp *; MyFile.java

javac -cp"*" MyFile.java

javac -cp "*" MyFile.java

javac -cp"*;" MyFile.java

javac -cp "*;" MyFile.java

在记录中没有任何地方提到afaik这个重要事实.

Nowhere in the documention is this important fact mentioned afaik.

所以我猜想在Java 1.6.0_75的WINDOWS 7 64位上,无论是使用双引号还是在使用WILDCARD时总是使用半冒号*

So I guess ON WINDOWS 7 64 bit, with java 1.6.0_75 EITHER USE DOUBLE QUOTES OR ALWAYS A SEMI-COLON WHEN USING WILDCARD *

这篇关于javac classpath选项在当前目录中有多个jar文件导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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