从.bat文件运行jar时出错

时间:2012-10-08 04:46:09

标签: java eclipse exception jar unsupported-class-version

我从UnSupportedClassVersionNumber致电jar时收到.bat file例外。

set LIBRARY_PATH=D:\endecabatch\JAR

echo %LIBRARY_PATH%

set JAVA_HOME=C:\Java\jdk1.5.0_14 

set PATH=%JAVA_HOME%\bin;%JAVA_HOME%\lib

set CLASSPATH=%PATH%

set CLASSPATH=%CLASSPATH%;%LIBRARY_PATH%\sqljdbc.jar

set CLASSPATH=%CLASSPATH%;%LIBRARY_PATH%\log4j-1.2.16.jar

set CLASSPATH=%CLASSPATH%;%LIBRARY_PATH%\auditlog_1.0.jar

set CLASSPATH=%CLASSPATH%;%LIBRARY_PATH%\jdbc_1.0.jar

set CLASSPATH=%CLASSPATH%;%LIBRARY_PATH%\EndecaBatch.jar

java -classpath %CLASSPATH% com.heb.endeca.batch.BatchManager "D:\endecabatch\" "properties\LOCAL\" "FULL" "ALL" 

从eclipse我已经导出了jar。我已将jre to 1.5.0_14和编译器版本更改为1.5,然后导出jar。它仍然显示相同的错误。请帮忙。

这是Exception我正在

D:\endecabatch>echo D:\endecabatch\JAR
D:\endecabatch\JAR

D:\endecabatch>set JAVA_HOME=C:\Java\jdk1.5.0_14

D:\endecabatch>set PATH=C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib

D:\endecabatch>set CLASSPATH=C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib

D:\endecabatch>set CLASSPATH=C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib;D:\endecabatch\JAR\sqljdbc.jar

D:\endecabatch>set CLASSPATH=C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib;D:\endecabatch\JAR\sqljdbc.jar;D:\endecabatch\JAR\log4j-1.2.16.jar

D:\endecabatch>set CLASSPATH=C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib;D:\endecabatch\JAR\sqljdbc.jar;D:\endecabatch\JAR\log4j-1.2.16.jar;D:\endecabatch\JAR\auditlog_1.0.jar

D:\endecabatch>set CLASSPATH=C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib;D:\endecabatch\JAR\sqljdbc.jar;D:\endecabatch\JAR\log4j-1.2.16.jar;D:\endecabatch\JAR\auditlog_1.0.jar;D:\endecabatch\JAR\jdbc_1.0.jar

D:\endecabatch>set CLASSPATH=C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib;D:\endecabatch\JAR\sqljdbc.jar;D:\endecabatch\JAR\log4j-1.2.16.jar;D:\endecabatch\JAR\auditlog_1.0.jar;D:\endecabatch\JAR\jdbc_1.0.jar;D:\endecabatch\JAR\EndecaBatch.jar

D:\endecabatch>java -classpath C:\Java\jdk1.5.0_14\bin;C:\Java\jdk1.5.0_14\lib;D:\endecabatch\JAR\sqljdbc.jar;D:\endecabatch\JAR\log4j-1.2.16.jar;D:\endecabatch\JAR\auditlog_1.0.jar;D:\endecabatch\JAR\jdbc_1.0.jar;D:\endecabatch\JAR\EndecaBatch.jar com.heb.endeca.batch.BatchManager "D:\endecabatch\" "properties\LOCAL\" "FULL" "ALL"
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    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:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

1 个答案:

答案 0 :(得分:0)

实际上我在生成jar时犯了一个错误。我在windows-> Preferences中更改了编译器版本,而不是在buildPath -> ConfigureBuildPath -> compiler

中更改它

现在我可以正确运行批处理文件中的java应用程序了。