javac classpath option with multiple jar files in current directory causing error

后端 未结 2 376
庸人自扰
庸人自扰 2020-12-11 04:28

Environment: Windows 7, Java 6.

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 othe

相关标签:
2条回答
  • 2020-12-11 05:05

    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

    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

    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

    Nowhere in the documention is this important fact mentioned afaik.

    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 *

    0 讨论(0)
  • 2020-12-11 05:27

    use backslash in windows?

    try

    javac -cp .\* MyFile.java

    also note Broken wildcard expansion for Java7 commandline on Windows(7?)

    0 讨论(0)
提交回复
热议问题