制作了一个jar包,遇到一个奇怪的问题,打好的jar包使用命令java -jar test.jar或test.jar或双击,可以正确运行,但是在cmd中用java test.jar运行,提示下面的错误:
C:\Users\Administrator>D:\work\temp\classes\java test.jar
Exception in thread "main" java.lang.NoClassDefFoundError: D:\work\temp\classes\test/jar
Caused by: java.lang.ClassNotFoundException: D:\work\temp\classes\test.jar
at java.net.URLClassLoader$1.run(Unknown Source)
&n..这是为什么呢?谢谢!
C:\Users\Administrator>D:\work\temp\classes\java test.jar
Exception in thread "main" java.lang.NoClassDefFoundError: D:\work\temp\classes\test/jar
Caused by: java.lang.ClassNotFoundException: D:\work\temp\classes\test.jar
at java.net.URLClassLoader$1.run(Unknown Source)
&n..这是为什么呢?谢谢!
java命令运行jar文件时,规定要带上参数E:\Documents and Settings\user>java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client. -cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
类似的这样写下 试试
@echo offset PROGRAMN_HOME=%cd%echo %PROGRAMN_HOME%set CLASSPATH=%CLASSPATH%;%PROGRAMN_HOME%\LLog.jar
set CLASSPATH=%CLASSPATH%;%PROGRAMN_HOME%\mysql-connector-java-5.1.6.jarjava com.generalfu.start.LLogStart