gpt4 book ai didi

java - 从命令提示符运行批处理文件出现错误

转载 作者:行者123 更新时间:2023-12-02 06:17:43 26 4
gpt4 key购买 nike

嗨,我有一个批处理文件,它基本上通过运行作业来更新数据库中的某些表。

这是批处理文件代码:

set CLASSPATH=C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\selenium-server-standalone-2.32.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jsoup-1.7.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xstream-1.1.3.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\XmlSchema-1.4.7.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-http-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\log4j-1.2.17.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\mysql-connector-java-5.1.13.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\httpclient-4.1.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\httpcore-4.1.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\commons-httpclient-3.0.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\gson-1.6.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\lucene-core-3.3.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-adb-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axiom-api-1.2.12.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-kernel-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\wsdl4j-1.6.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\XmlSchema-1.4.7.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axiom-impl-1.2.12.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\neethi-3.0.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\freemarker.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\smtp.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-local-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-http-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\mailapi.jar;
C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-context-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-core-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-beans-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-asm-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-aop-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-tx-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\aopalliance-1.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-expression-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-orm-3.1.1.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\transactions-jdbc-3.8.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\transactions-osgi-3.8.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\hibernate-3.2.1.ga.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\hibernate-annotations-3.2.0.ga.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jboss-transaction-api_1.1_spec-1.0.0.Final.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-jdbc-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\dom4j-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\transactions-hibernate3-3.8.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\gdata-core-1.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xstream-1.1.3.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\commons-lang-2.3.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xmlunit-1.5.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\log4j-1.2.17.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-http-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\mailapi.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\antlr-2.7.7.jar;
C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;

java -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m com.myProject.batch.PropertyRatesUpdaterBatchJob

我正在尝试从命令提示符运行批处理文件,但收到类似错误

C:\ProjectWorkSpace\myProject\tools>C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;
'C:\ProjectWorkSpace\myProject\web\WEB-INF\classes' is not recognized as an internal or external command,
operable program or batch file.

最后我得到的第二个错误是

Exception in thread "main" java.lang.NoClassDefFoundError: com/myProject/batch    /PropertyRatesUpdaterBatchJob
Caused by: java.lang.ClassNotFoundException: com.myProject.batch.PropertyRatesUpdaterBatchJob
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

并且我无法运行批处理文件。任何人都可以帮助我了解如何运行相同的内容以及此错误的含义。

您好,这是我的新批处理文件:

    set CLASSPATH=C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\selenium-server-standalone-2.32.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\jsoup-1.7.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\xstream-1.1.3.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\XmlSchema-1.4.7.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-http-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\log4j-1.2.17.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\mysql-connector-java-5.1.13.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\httpclient-4.1.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\httpcore-4.1.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\commons-httpclient-3.0.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\gson-1.6.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\lucene-core-3.3.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-adb-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axiom-api-1.2.12.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-kernel-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\wsdl4j-1.6.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\XmlSchema-1.4.7.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axiom-impl-1.2.12.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\neethi-3.0.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\freemarker.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\smtp.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-local-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-http-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\mailapi.jar;C:\ProjectWorkSpace\zaranga\WEB-INF\classes;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-context-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-core-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-beans-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-asm-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-aop-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-tx-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\aopalliance-1.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-expression-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-orm-3.1.1.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\transactions-jdbc-3.8.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\transactions-osgi-3.8.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\hibernate-3.2.1.ga.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\hibernate-annotations-3.2.0.ga.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\jboss-transaction-api_1.1_spec-1.0.0.Final.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-jdbc-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\dom4j-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\transactions-hibernate3-3.8.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\gdata-core-1.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\xstream-1.1.3.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\commons-lang-2.3.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\xmlunit-1.5.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\log4j-1.2.17.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-http-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\mailapi.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\antlr-2.7.7.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\classes

java -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m com.zaranga.batch.PropertyRatesUpdaterBatchJob

现在我收到一个新错误 log4j 作为错误是:

No org.slf4j.impl.StaticLoggerBinder found in ClassPath, trying with log4j...

任何帮助将不胜感激。

最佳答案

我假设

set CLASSPATH=C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\selenium-server-standalone-2.32.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jsoup-1.7.2.jar;

您还想将 jsoup-1.7.2.jar; 添加到 CLASSPATH 变量,但您不能像这样将命令扩展到多行。

如果你想把它写在多行上,每一行(当然最后一行除外)必须以所谓的“行继续字符”结束,它告诉Windows该命令(在您的情况 SET) 尚未完成,即使该行已完成。该字符在 Windows 中为 ^(相当于 Linux/Unix shell 脚本中的 \)

所以你需要的是:

set CLASSPATH=C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\selenium-server-standalone-2.32.0.jar; ^
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jsoup-1.7.2.jar; ^
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xstream-1.1.3.jar; ^
.... ^
.... ^
C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;

java -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m com.myProject.batch.PropertyRatesUpdaterBatchJob

(顺便说一句:您的列表中有两次 C:\ProjectWorkSpace\myProject\web\WEB-INF\classes)

您必须确保 ^ 之后没有任何空格,否则这将不起作用。

顺便说一句:您不应该再使用 CLASSPATH 变量。最好使用 -cp(或 java 命令的 -classpath 参数)显式定义类路径。

在最近(最新)版本的 Windows 版 Java 中,您无需指定类路径变量中的每个元素。

引自http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

As a special convenience, a class path element that contains a base name of * is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR

所以你可以摆脱所有的行并只使用:

java -cp C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\*;C:\ProjectWorkSpace\myProject\web\WEB-INF\classes  com.myProject.batch.PropertyRatesUpdaterBatchJob

关于java - 从命令提示符运行批处理文件出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21301953/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com