我尝试设置输入路径的Path环境变量:" C:\ Program Files \ Java \ jdk1.8.0_101 \ db \ lib" (.jar文件路径)但没有... 我通过输入相同的路径创建了一个名为CLASSPATH的新变量,但仍然没有... 如何将此路径链接到编译器?
答案 0 :(得分:0)
You can't set CLASSPATH to the directory where the jar files are stored; you have to specify the actual jar file by its full name.
This is a difference between a directory full of java .class files, versus a directory full of java .jar files.
So set your CLASSPATH to:
c:\Program Files\Java\jdk1.8.0_101\db\lib\derby.jar;c:\Program Files\Java\jdk1.8.0_101\db\lib\derbyclient.jar
In your particular case, since the only class you're trying to reference is ClientDriver
, which is in derbyclient.jar
, you could just set CLASSPATH to c:\Program Files\Java\jdk1.8.0_101\db\lib\derbyclient.jar
and leave derby.jar
out, but at some point in the future you might want to reference other Derby classes, such as EmbeddedDriver
, so you might as well put both derby.jar
and derbyclient.jar
into your CLASSPATH now.