Java 由于“输入行太长”,在 Windows 上运行 .bat 文件时出现问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1503708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problem running .bat file on Windows due to "input line is too long"
提问by eldoctoro
I'm using Windows and have a batch file (contents attached below) where I'm building up a classpath before trying to run a Java class. Unfortunately the classpath is fairly big and the file ends up being ~14kb. When I run it I'm getting an 'input line too long' error. I have read elsewhere that the max. size for an env variable is 8kb, but it looks unlikely that I'll be able to reduce the size of my classpath to fit that. Is there anything else I can do to get this to run?
我正在使用 Windows 并有一个批处理文件(下面附有内容),我在尝试运行 Java 类之前在其中构建了一个类路径。不幸的是,类路径相当大,文件最终约为 14kb。当我运行它时,我收到“输入行太长”错误。我在其他地方读过最大。env 变量的大小是 8kb,但我似乎不太可能减少我的类路径的大小以适应它。我还能做些什么来让它运行?
thanks, Nick
谢谢,尼克
echo off
subst z: C:\Users\ned24\.m2\repository
set CLASSPATH=c:\workspace-eclipse\lensfield-pom\lensfield-build\target\classes;%CLASSPATH%
set CLASSPATH=z:\wwmm\atom-archiverjava -cp libs/* com.mypackage.MyProgram
.1\atom-archiver-0.1.jar;%CLASSPATH%
set CLASSPATH=z:\commons-lang\commons-lang.4\commons-lang-2.4.jar;%CLASSPATH%
set CLASSPATH=z:\commons-io\commons-io.4\commons-io-1.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\freemarker\freemarker.3.9\freemarker-2.3.9.jar;%CLASSPATH%
set CLASSPATH=z:\log4j\log4j.2.13\log4j-1.2.13.jar;%CLASSPATH%
set CLASSPATH=z:\xom\xom.1\xom-1.1.jar;%CLASSPATH%
set CLASSPATH=z:\xerces\xmlParserAPIs.6.2\xmlParserAPIs-2.6.2.jar;%CLASSPATH%
set CLASSPATH=z:\xerces\xercesImpl.6.2\xercesImpl-2.6.2.jar;%CLASSPATH%
set CLASSPATH=z:\xalan\xalan.7.0\xalan-2.7.0.jar;%CLASSPATH%
set CLASSPATH=z:\xml-apis\xml-apis.0.b2\xml-apis-1.0.b2.jar;%CLASSPATH%
set CLASSPATH=z:\jaxen\jaxen.1-beta-8\jaxen-1.1-beta-8.jar;%CLASSPATH%
set CLASSPATH=z:\dom4j\dom4j.6.1\dom4j-1.6.1.jar;%CLASSPATH%
set CLASSPATH=z:\jdom\jdom.0\jdom-1.0.jar;%CLASSPATH%
set CLASSPATH=z:\cdk\cdk-pure.2.1\cdk-pure-1.2.1.jar;%CLASSPATH%
set CLASSPATH=z:\cml\cifxml.4-SNAPSHOT\cifxml-1.4-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\jgrapht\jgrapht
set PLEXHOME=z:\org\codehaus\plexus\plexus-component-annotations.0-beta-3.0.5\plexus-component-annotations-1.0-beta-3.0.5.jar
set CLASSPATH=%PLEXHOME%;%CLASSPATH%
set WAGONHOME=z:\org\apache\maven\wagon\wagon-provider-api.0-beta-4\wagon-provider-api-1.0-beta-4.jar
set CLASSPATH=%WAGONHOME%;%CLASSPATH%
set MAVENAPIHOME=z:\org\apache\maven\maven-plugin-api.0-alpha-2\maven-plugin-api-3.0-alpha-2.jar
set CLASSPATH=%MAVENAPIHOME%;%CLASSPATH%
...
.6.0\jgrapht-0.6.0.jar;%CLASSPATH%
set CLASSPATH=z:\cml\jumbo-converters##代码##.2-SNAPSHOT\jumbo-converters-0.2-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\cml\jumbo.5.1-SNAPSHOT\jumbo-5.5.1-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\cml\cmlxom.5.1-SNAPSHOT\cmlxom-2.5.1-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\junit\junit.8\junit-3.8.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\commons\commons-cli.0-SNAPSHOT\commons-cli-2.0-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\cml\jumbo-units##代码##.2-SNAPSHOT\jumbo-units-0.2-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\org\lensfield\lensfield-share##代码##.1-SNAPSHOT\lensfield-share-0.1-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-embedder.0-alpha-2\maven-embedder-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-core.0-alpha-2\maven-core-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-lifecycle.0-alpha-2\maven-lifecycle-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\plexus\plexus-utils.5.6\plexus-utils-1.5.6.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-reporting-api.0-alpha-2\maven-reporting-api-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\doxia\doxia-sink-api.0-alpha-9\doxia-sink-api-1.0-alpha-9.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-model.0-alpha-2\maven-model-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-compat.0-alpha-2\maven-compat-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\plexus\plexus-container-default.0-beta-3.0.5\plexus-container-default-1.0-beta-3.0.5.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\plexus\plexus-classworlds.3\plexus-classworlds-1.3.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\xbean\xbean-reflect.4\xbean-reflect-3.4.jar;%CLASSPATH%
set CLASSPATH=z:\commons-logging\commons-logging-api.1\commons-logging-api-1.1.jar;%CLASSPATH%
set CLASSPATH=z:\com\google\code\google-collections\google-collect\snapshot-20080530\google-collect-snapshot-20080530.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\plexus\plexus-component-annotations.0-beta-3.0.5\plexus-component-annotations-1.0-beta-3.0.5.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\wagon\wagon-provider-api.0-beta-4\wagon-provider-api-1.0-beta-4.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-plugin-api.0-alpha-2\maven-plugin-api-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-project.0-alpha-2\maven-project-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\plexus\plexus-interpolation.1\plexus-interpolation-1.1.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\woodstox\wstx-asl.2.6\wstx-asl-3.2.6.jar;%CLASSPATH%
set CLASSPATH=z:\stax\stax-api.0\stax-api-1.0.jar;%CLASSPATH%
set CLASSPATH=z:\org\sonatype\spice\model-builder.3\model-builder-1.3.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-project-builder.0-alpha-2\maven-project-builder-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\commons-cli\commons-cli.0\commons-cli-1.0.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\plexus\plexus-interactivity-api.0-alpha-6\plexus-interactivity-api-1.0-alpha-6.jar;%CLASSPATH%
set CLASSPATH=z:\org\sonatype\plexus\plexus-plugin-manager.0-alpha-1\plexus-plugin-manager-1.0-alpha-1.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-plexus.0.0-alpha-2\mercury-plexus-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-repo-remote-m2.0.0-alpha-2\mercury-repo-remote-m2-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-repo-api.0.0-alpha-2\mercury-repo-api-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-artifact.0.0-alpha-2\mercury-artifact-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\codehaus\plexus\plexus-lang.1\plexus-lang-1.1.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-transport-api.0.0-alpha-2\mercury-transport-api-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-crypto-api.0.0-alpha-2\mercury-crypto-api-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-logging.0.0-alpha-2\mercury-logging-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-external.0.0-alpha-2\mercury-external-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-event.0.0-alpha-2\mercury-event-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-md-shared.0.0-alpha-2\mercury-md-shared-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-util.0.0-alpha-2\mercury-util-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-crypto-basic.0.0-alpha-2\mercury-crypto-basic-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\bouncycastle\bcprov-jdk150\bcprov-jdk15-140.jar;%CLASSPATH%
set CLASSPATH=z:\bouncycastle\bcpg-jdk150\bcpg-jdk15-140.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-transport-http.0.0-alpha-2\mercury-transport-http-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\mortbay\jetty\jetty-client.1.12\jetty-client-6.1.12.jar;%CLASSPATH%
set CLASSPATH=z:\org\mortbay\jetty\jetty-sslengine.1.12\jetty-sslengine-6.1.12.jar;%CLASSPATH%
set CLASSPATH=z:\org\mortbay\jetty\jetty.1.12\jetty-6.1.12.jar;%CLASSPATH%
set CLASSPATH=z:\org\mortbay\jetty\jetty-util.1.12\jetty-util-6.1.12.jar;%CLASSPATH%
set CLASSPATH=z:\org\mortbay\jetty\servlet-api-2.5.1.12\servlet-api-2.5-6.1.12.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-repo-local-m2.0.0-alpha-2\mercury-repo-local-m2-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-repo-virtual.0.0-alpha-2\mercury-repo-virtual-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-repo-cache-fs.0.0-alpha-2\mercury-repo-cache-fs-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\mercury\mercury-md-sat.0.0-alpha-2\mercury-md-sat-1.0.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\sat4j\org.sat4j.core.0.4\org.sat4j.core-2.0.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\sat4j\org.sat4j.pb.0.4\org.sat4j.pb-2.0.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\slf4j\slf4j-jdk14.5.3\slf4j-jdk14-1.5.3.jar;%CLASSPATH%
set CLASSPATH=z:\org\slf4j\slf4j-api.5.0\slf4j-api-1.5.0.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-mercury.0-alpha-2\maven-mercury-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\maven-toolchain.0-alpha-2\maven-toolchain-3.0-alpha-2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\wagon\wagon-http-lightweight.0-beta-4\wagon-http-lightweight-1.0-beta-4.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\wagon\wagon-http-shared.0-beta-4\wagon-http-shared-1.0-beta-4.jar;%CLASSPATH%
set CLASSPATH=z:\nekohtml\xercesMinimal.9.6.2\xercesMinimal-1.9.6.2.jar;%CLASSPATH%
set CLASSPATH=z:\nekohtml\nekohtml.9.6.2\nekohtml-1.9.6.2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\wagon\wagon-ssh.0-beta-4\wagon-ssh-1.0-beta-4.jar;%CLASSPATH%
set CLASSPATH=z:\com\jcraft\jsch##代码##.1.38\jsch-0.1.38.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\wagon\wagon-ssh-common.0-beta-4\wagon-ssh-common-1.0-beta-4.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\wagon\wagon-ssh-external.0-beta-4\wagon-ssh-external-1.0-beta-4.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\maven\wagon\wagon-file.0-beta-4\wagon-file-1.0-beta-4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-repository-api.2.4\sesame-repository-api-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-query.2.4\sesame-query-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-model.2.4\sesame-model-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-collections.3\aduna-commons-collections-2.3.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-concurrent.2\aduna-commons-concurrent-2.2.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-iteration.3\aduna-commons-iteration-2.3.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-i18n.0\aduna-commons-i18n-1.0.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-rio-api.2.4\sesame-rio-api-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-lang.3\aduna-commons-lang-2.3.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-net.2\aduna-commons-net-2.2.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-text.2\aduna-commons-text-2.2.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-io.4\aduna-commons-io-2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-queryresultio-api.2.4\sesame-queryresultio-api-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-queryparser-sparql.2.4\sesame-queryparser-sparql-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-queryparser-api.2.4\sesame-queryparser-api-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-queryalgebra-model.2.4\sesame-queryalgebra-model-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-repository-sail.2.4\sesame-repository-sail-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-sail-api.2.4\sesame-sail-api-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-sail-nativerdf.2.4\sesame-sail-nativerdf-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-sail-inferencer.2.4\sesame-sail-inferencer-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-queryparser-serql.2.4\sesame-queryparser-serql-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-queryalgebra-evaluation.2.4\sesame-queryalgebra-evaluation-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-queryresultio-sparqlxml.2.4\sesame-queryresultio-sparqlxml-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\info\aduna\commons\aduna-commons-xml.2\aduna-commons-xml-2.2.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-rio-rdfxml.2.4\sesame-rio-rdfxml-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\openrdf\sesame\sesame-rio-turtle.2.4\sesame-rio-turtle-2.2.4.jar;%CLASSPATH%
set CLASSPATH=z:\net\sourceforge\jena\jena.4\jena-2.4.jar;%CLASSPATH%
set CLASSPATH=z:\antlr\antlr.7.5\antlr-2.7.5.jar;%CLASSPATH%
set CLASSPATH=z:\net\sourceforge\jena\arq.4\arq-1.4.jar;%CLASSPATH%
set CLASSPATH=z:\net\sourceforge\jena\iri.0\iri-1.0.jar;%CLASSPATH%
set CLASSPATH=z:\commons-logging\commons-logging.1\commons-logging-1.1.jar;%CLASSPATH%
set CLASSPATH=z:\logkit\logkit.0.1\logkit-1.0.1.jar;%CLASSPATH%
set CLASSPATH=z:\avalon-framework\avalon-framework.1.3\avalon-framework-4.1.3.jar;%CLASSPATH%
set CLASSPATH=z:\javax\servlet\servlet-api.3\servlet-api-2.3.jar;%CLASSPATH%
set CLASSPATH=z:\concurrent\concurrent.3.4\concurrent-1.3.4.jar;%CLASSPATH%
set CLASSPATH=z:\icu4j\icu4j.4\icu4j-3.4.jar;%CLASSPATH%
set CLASSPATH=z:\org\json\json.0\json-1.0.jar;%CLASSPATH%
set CLASSPATH=z:\woodstox\wstx-asl.8\wstx-asl-2.8.jar;%CLASSPATH%
set CLASSPATH=z:\owlapi\owlapi.2.0\owlapi-2.2.0.jar;%CLASSPATH%
set CLASSPATH=z:\org\slf4j\slf4j-log4j12.4.2\slf4j-log4j12-1.4.2.jar;%CLASSPATH%
set CLASSPATH=z:\org\clojure\clojure-lang.1.0-alpha-SNAPSHOT\clojure-lang-1.1.0-alpha-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\org\clojure\clojure-contrib.0-SNAPSHOT\clojure-contrib-1.0-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\wwmm\pub-crawler##代码##.1\pub-crawler-0.1.jar;%CLASSPATH%
set CLASSPATH=z:\commons-httpclient\commons-httpclient.1\commons-httpclient-3.1.jar;%CLASSPATH%
set CLASSPATH=z:\commons-codec\commons-codec.2\commons-codec-1.2.jar;%CLASSPATH%
set CLASSPATH=z:\org\dspace\foresite\SNAPSHOT\foresite-SNAPSHOT.jar;%CLASSPATH%
set CLASSPATH=z:\com\hp\hpl\jena\jena.5.5\jena-2.5.5.jar;%CLASSPATH%
set CLASSPATH=z:\com\hp\hpl\jena\arq.2\arq-2.2.jar;%CLASSPATH%
set CLASSPATH=z:\org\apache\lucene\lucene-core.2.0\lucene-core-2.2.0.jar;%CLASSPATH%
set CLASSPATH=z:\com\hp\hpl\jena\arq-extra.2\arq-extra-2.2.jar;%CLASSPATH%
set CLASSPATH=z:\com\hp\hpl\jena\jenatest.5.5\jenatest-2.5.5.jar;%CLASSPATH%
set CLASSPATH=z:\com\hp\hpl\jena\iri##代码##.5\iri-0.5.jar;%CLASSPATH%
set CLASSPATH=z:\com\ibm\icu\icu4j.4.4\icu4j-3.4.4.jar;%CLASSPATH%
set CLASSPATH=z:\com\hp\hpl\jena\concurrent-jena.3.2\concurrent-jena-1.3.2.jar;%CLASSPATH%
set CLASSPATH=z:\com\hp\hpl\jena\json-jena.0\json-jena-1.0.jar;%CLASSPATH%
set CLASSPATH=z:\rome\rome##代码##.9\rome-0.9.jar;%CLASSPATH%
set CLASSPATH=z:\org\ccil\cowan\tagsoup\tagsoup.0.1\tagsoup-1.0.1.jar;%CLASSPATH%
set CLASSPATH=z:\javax\vecmath.2\vecmath-1.2.jar;%CLASSPATH%
java clojure.main "%LENSFIELD_HOME%\lensfield-build\src\main\clj\lensfield\cli.clj" %*
采纳答案by Jesper
If you are using Java 6, you can use a wildcard in the classpath, for example:
如果您使用的是 Java 6,则可以在类路径中使用通配符,例如:
##代码##See the documentation(scroll down to "Understanding class path wildcards") for more details.
有关更多详细信息,请参阅文档(向下滚动到“了解类路径通配符”)。
Note: This doesn't work on older versions of Java.
注意:这不适用于旧版本的 Java。
回答by Joey
The maximum size for an environment variable is around 32760 characters. However, the maximum size for a single command line in cmd
(and therefore in batch files) is 8190 characters.
环境变量的最大大小约为 32760 个字符。但是,单个命令行cmd
(因此在批处理文件中)的最大大小为8190 个字符。
Since you're building a very long CLASSPATH
variable here you encounter that limitation, even though the environment variable in question can still be much longer. Delayed expansion probably won't help here since it still results in a unwieldy long command line.
由于您在CLASSPATH
这里构建了一个很长的变量,因此您会遇到该限制,即使有问题的环境变量仍然可以更长。延迟扩展在这里可能无济于事,因为它仍然会导致笨拙的长命令行。
Currently I see two options:
目前我看到两个选项:
- Use VBScript instead of a batch file. I guess1that it supports lines longer than that. Also you are not forced to have the entire classpath written out in a single line of code; it can easily be in a string.
- Use
setx
, included with Windows Vista or later, or in the Windows Resource kit before that.setx
allows you to read from a file, but it also writes directly to the registry, so it's essentially equivalent to setting the classpath in your user's environment (instead of only for a single process).
- 使用 VBScript 而不是批处理文件。我猜1它支持比这更长的行。您也不会被迫在一行代码中写出整个类路径;它可以很容易地在一个字符串中。
- 使用
setx
,包含在 Windows Vista 或更高版本中,或在此之前的 Windows 资源工具包中。setx
允许您从文件中读取,但它也直接写入注册表,因此它本质上等同于在用户环境中设置类路径(而不是仅用于单个进程)。
1I'm nowhere sure but it doesn't inherit the legacy codebase of cmd
so it might be a reasonable assumption.
1我不确定,但它没有继承遗留代码库,cmd
所以这可能是一个合理的假设。
回答by Daniel A. White
Why are you hunting for the java class path? If you know where the class is, then just call that class by the direct path name, not its file name.
你为什么要寻找 java 类路径?如果您知道该类的位置,则只需通过直接路径名调用该类,而不是其文件名。
回答by unwind
You might be able to refactor by defining more drive letters, i.e. if you had W: to point at "z:\org\apache\maven\" that ought to cut out a few characters. Repeat that a couple of times, and you might get low enough for it to work.
您可能能够通过定义更多驱动器号来重构,即如果您有 W: 指向“z:\org\apache\maven\”,这应该删除一些字符。重复几次,您可能会变得足够低以使其工作。
回答by lavinio
Do any of those jars care where they live? Could you just have the batch file copy them all into a localjar directory, and then you could just list them?
这些罐子中的任何一个关心他们住在哪里吗?您可以让批处理文件将它们全部复制到 localjar 目录中,然后您就可以列出它们吗?
You could use xcopy /d/y
, which only copies if the file has changed.
您可以使用xcopy /d/y
,它仅在文件已更改时进行复制。
回答by Frank Bollack
Instead of the subst
command you could try to create short symbolic links to all the directories where your JARs reside. Use the free junction
tool from the Windows Sysinternals Suite to achieve this.
subst
您可以尝试创建指向 JAR 所在的所有目录的短符号链接,而不是该命令。使用junction
Windows Sysinternals Suite 中的免费工具来实现此目的。
[...]
Using Junction
Use junction to list junctions:
Usage: [-s]
-s Recurse subdirectories
Examples:
To determine if a file is a junction, specify the file name:
junction c:\test
To list junctions beneath a directory, include the –s switch:
junction -s c:\
To create a junction c:\Program-Files for "c:\Program Files":
C:\>md Program-Files
C:\>junction c:\Program-Files "c:\Program Files"
To delete a junction, use the –d switch:
junction -d c:\Program-Files
[...]
使用连接点
使用结点列出结点:
用法:[-s]
-s 递归子目录
例子:
要确定文件是否为联结,请指定文件名:
junction c:\test
要列出目录下的联结,请包括 –s 开关:
junction -s c:\
要为“c:\Program Files”创建连接 c:\Program-Files:
C:\>md Program-Files
C:\>junction c:\Program-Files "c:\Program Files"
要删除结点,请使用 –d 开关:
junction -d c:\Program-Files
回答by Yishai
Another option if you are running vista and java 6 is to make a directory with symbolic links using the MKLINKcommand so that all the jars appear in one directory, and then use the java 6 ability to reference all of the jars with a *.jar.
如果您正在运行 vista 和 java 6,另一种选择是使用MKLINK命令创建一个带有符号链接的目录,以便所有 jar 都出现在一个目录中,然后使用 java 6 功能使用 *.jar 引用所有 jar .
I think the other answers pretty much exhaust the windows options, but another option is to make a wrapper jar that invokes the clojure.main and puts all of these jars in its classpath.
我认为其他答案几乎耗尽了 windows 选项,但另一种选择是制作一个调用 clojure.main 的包装器 jar 并将所有这些 jars 放在其类路径中。
回答by CPerkins
I'm not completely au courant on Windows specifics, but given that you're having a command line problem, and not a variable size problem, can't you define variables and use those? For example:
我对 Windows 的细节并不完全了解,但鉴于您遇到的是命令行问题,而不是可变大小的问题,您不能定义变量并使用它们吗?例如:
##代码##回答by aledbf
The problem is in the first set CLASSPATH=....;%CLASSPATH% just eliminate the %CLASSPATH% at the end. The error isn't descriptive, but is because %CLASSPATH% has not value.
问题出在第一组 CLASSPATH=....;%CLASSPATH% 只是在最后消除了 %CLASSPATH% 。该错误不是描述性的,而是因为 %CLASSPATH% 没有值。
回答by Snehal Masne
For me, there was no solution worked to the issue other than somehow making the classpath shorter by moving the jar files into a folder like "C:\jars".
对我来说,除了通过将 jar 文件移动到“C:\jars”之类的文件夹中以某种方式缩短类路径之外,没有其他解决方案可以解决这个问题。