This exception tells that the mentioned class is missing in the runtime classpath.
There are several ways to specify the runtime classpath, depending on how you're executing the program. Since a decent IDE takes this all transparently from your hands, I bet that you're running it in a command prompt.
If you're running it as a JAR file by java.exe -jar
or doubleclicking the file, then you need to specify the classpath in the Class-Path
entry of the JAR's MANIFEST.MF
file. Note that the %CLASSPATH%
environment variable and -cp
and -classpath
arguments are ignored whenever you execute a JAR.
If you're running it as a "plain vanilla" Java application by java.exe
, then you need to specify it in the -cp
or -classpath
argument. Note that whenever you use this argument, the %CLASSPATH%
environment variable is ignored.
Either way, the classpath should exist of a (semi)colonseparated string of paths to JAR files (either absolute paths or relative to current working directory). E.g.
java -cp .;/path/to/file1.jar;/path/to/file2.jar com.example.MyClass
(if you're on Unix/Linux, use colon instead of semicolon as path separator)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…