美橙互联网站打不开,山东省建设文化传媒有限公司网站,站酷网素材图库海报设计,免费软件在线下载有没有一种方法可以将所有的jar文件包含在类路径的目录中#xff1f;我正在尝试java -classpath lib / *。jar :. my.package.Program#xff0c;它无法找到当然在这些罐子里的类文件。我是否需要将每个jar文件分别添加到类路径中#xff1f;使用Java 6或更高版本#xff0…有没有一种方法可以将所有的jar文件包含在类路径的目录中我正在尝试java -classpath lib / *。jar :. my.package.Program它无法找到当然在这些罐子里的类文件。我是否需要将每个jar文件分别添加到类路径中使用Java 6或更高版本classpath选项支持通配符。请注意以下几点使用直引号(“)”使用*而不是*。jar窗java -cp Test.jar;lib/* my.package.MainClass的Unixjava -cp Test.jar:lib/* my.package.MainClass这与Windows类似但使用而不是;。如果不能使用通配符bash允许使用以下语法(其中lib是包含所有Java归档文件的目录)java -cp $(echo lib/*.jar | tr :)(请注意使用类路径与-jar选项不兼容。另请参见从命令提示符执行带有多个classpath库的jar文件)了解通配符从Classpath文件/ pClass path entries can contain the basename wildcard character *, which isconsidered equivalent to specifying a list of all the files in the directorywith the extension .jar or .JAR. For example, the class path entry foo/*specifies all JAR files in the directory named foo. A classpath entryconsisting simply of * expands to a list of all the jar files in the currentdirectory.A class path entry that contains * will not match class files. To matchboth classes and JAR files in a single directory foo, use either foo;foo/*or foo/*;foo. The order chosen determines whether the classes and resourcesin foo are loaded before JAR files in foo, or vice versa.Subdirectories are not searched recursively. For example, foo/* looks forJAR files only in foo, not in foo/bar, foo/baz, etc.The order in which the JAR files in a directory are enumerated in theexpanded class path is not specified and may vary from platform to platformand even from moment to moment on the same machine. A well-constructedapplication should not depend upon any particular order. If a specific orderis required then the JAR files can be enumerated explicitly in the class path.Expansion of wildcards is done early, prior to the invocation of a program’smain method, rather than late, during the class-loading process itself. Eachelement of the input class path containing a wildcard is replaced by the(possibly empty) sequence of elements generated by enumerating the JAR filesin the named directory. For example, if the directory foo contains a.jar,b.jar, and c.jar, then the class path foo/* is expanded intofoo/a.jar;foo/b.jar;foo/c.jar, and that string would be the value of thesystem property java.class.path.The CLASSPATH environment variable is not treated any differently from the-classpath (or -cp) command-line option. That is, wildcards are honored inall these cases. However, class path wildcards are not honored in the Class-Path jar-manifest header.在windows下这个工作java -cp Test.jar;lib/* my.package.MainClass这不起作用java -cp Test.jar;lib/*.jar my.package.MainClass注意.jar **所以应该单独使用通配符** 。在Linux上以下工作java -cp Test.jar:lib/* my.package.MainClass分隔符是冒号而不是分号。未经作者同意本文严禁转载违者必究